Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Authorize(Roles = "VPQT")]
- [Route("~/valorpneu/questionario/detentor/editar")]
- public ActionResult ValorPneuFormEmpresa(string oldaction, int qid = 0, int pid = 33, int fid = 34, int did = 0, string companyid = "")
- {
- var model = new ValorPneuFormEmpresaPageObject();
- if (Session["UserInfo"] != null)
- {
- var userInfo = (UserInfo)Session["UserInfo"];
- var userPageInfo = new UserPageInfo();
- if (Request.Url != null)
- {
- userInfo.UWL.BEFORE_URL = userInfo.UWL.CURRENT_URL;
- userInfo.UWL.CURRENT_URL = Request.Url.Scheme + "://" + Request.Url.Authority +
- Request.Url.PathAndQuery;
- }
- model = Database.ValorPneuFormEmpresa("pt");
- userPageInfo.BasicCompany = userInfo.UserCompany;
- userPageInfo.BasicUser = userInfo.User;
- userPageInfo.BasicUser.CURRENT_ACTION = "ValorPneuFormEmpresa";
- userPageInfo.BasicUser.CURRENT_CONTROLLER = "ValorPneu_Questionario";
- model.PAGE_OBJECT.PAGE_INFO.ACTION = "ValorPneuFormEmpresa";
- model.PAGE_OBJECT.PAGE_INFO.CONTROLLER = "ValorPneu_Questionario";
- model.PAGE_OBJECT.UserPageInfo = userPageInfo;
- ViewBag.UserPageInfo = userPageInfo;
- var aid = userInfo.User.ID_AGENCY;
- var cid = userInfo.User.ID_COMPANY;
- var sid = userInfo.User.ID_SBU;
- try
- {
- using (var database = new Entities())
- {
- database.Configuration.LazyLoadingEnabled = false;
- model.URL = Url.Action(oldaction, "ValorPneu_Questionario");
- model.OLDACTION = oldaction;
- model.PID = pid;
- model.FID = fid;
- model.QID = qid;
- model.hasQuest = "NO";
- var getCities = database.valorpneu_cidade_lista.ToList();
- if (getCities.Any())
- model.CITIES = getCities;
- if (!string.IsNullOrEmpty(companyid))
- {
- var getCompany = database.valorpneu_detentor_e_empresa.FirstOrDefault(p => p.ID_AGENCY == aid &&
- p.ID_COMPANY == cid &&
- p.ID_SBU == sid &&
- p.ID_NIF.Equals(companyid) &&
- p.ID_DETENTOR == did &&
- p.ID_QUESTIONARIO == qid);
- if (getCompany != null)
- {
- var getQuest = database.valorpneu_formulario_detentor.FirstOrDefault(
- p => p.ID_AGENCY == aid &&
- p.ID_COMPANY == cid &&
- p.ID_SBU == sid &&
- p.ID_QUESTIONARIO == qid);
- model.DETENTOR = getCompany;
- if (getCompany.RESPONDEU.Value == true)
- {
- model.hasQuest = "DONE";
- }
- else if(getQuest != null)
- {
- model.hasQuest = "OK";
- }
- }
- }
- else
- {
- model.DETENTOR = new valorpneu_detentor_e_empresa()
- {
- ID_NIF = "",
- ID_DETENTOR = 0,
- NOME_EMPRESA = string.Empty,
- CIDADE_EMPRESA = string.Empty,
- CONSELHO_EMPRESA = string.Empty,
- DISTRITO_EMPRESA = string.Empty,
- COD_POSTAL_EMPRESA = string.Empty,
- EMAIL_EMPRESA = string.Empty,
- TELF_EMPRESA = string.Empty,
- MORADA_EMPRESA = string.Empty,
- NOME_DETENTOR = string.Empty,
- CIDADE_DETENTOR = string.Empty,
- CONSELHO_DETENTOR = string.Empty,
- DISTRITO_DETENTOR = string.Empty,
- COD_POSTAL_DETENTOR = string.Empty,
- EMAIL_DETENTOR = string.Empty,
- TELF_DETENTOR = string.Empty,
- MORADA_DETENTOR = string.Empty,
- OBS = string.Empty,
- FUNCAO = string.Empty
- };
- }
- }
- }
- catch (EndpointNotFoundException ex)
- {
- TempData["LoginError"] = "Não foi possivel fazer a ligação á base de dados.";
- return RedirectToAction("LogOff", "Account");
- }
- catch (Exception ex)
- {
- TempData["Notification"] = HtmlExtentions.Notification(HtmlExtentions.PositionType.topRight,
- HtmlExtentions.NotificationType.error,
- "Ocorreu um Erro desconhecido ao tentar ver a empresa.",
- true, "", HtmlExtentions.AnimationType.fadeInDown, HtmlExtentions.AnimationType.fadeOut,
- 500, 5000, true, false, 1, true,
- HtmlExtentions.CloseType.click, "", false);
- return RedirectToAction("Index", "Home");
- }
- var breadcrumbCount = 0;
- var allNavPages = new List<PageNavigation>
- {
- UtilityExtentions.GetPageNavigation(breadcrumbCount + 1, Request.Url, "Index", "Home",
- new string[0]),
- UtilityExtentions.GetPageNavigation(breadcrumbCount + 1, Request.Url, "ValorPneuFormEmpresa",
- "ValorPneu_Questionario", new string[0], true)
- };
- //var allSideButtons = new SideBar
- //{
- // BUTTON_GROUPS = UtilityExtentions.UpdateSideButton(userInfo.UserSideBar.BUTTON_GROUPS,
- // "ValorPneuFormEmpresa", "ValorPneu_Questionario", new[] { "VPQT" })
- //};
- var allNavButtons = new TopMenu
- {
- TABS = UtilityExtentions.UpdateTab(userInfo.UserTopMenu.TABS, "VPQT")
- };
- model.PAGE_OBJECT.PAGE_TABS = allNavButtons;
- model.PAGE_OBJECT.PAGE_SIDEBAR = null;
- model.PAGE_OBJECT.PAGE_URLS = allNavPages;
- Session["UserInfo"] = userInfo; //update session
- }
- else
- {
- TempData["LoginError"] = "A sua sessão foi terminada ou expirou.";
- return RedirectToAction("Index", "Account");
- }
- return View("ValorPneuFormEmpresa", model);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement