Esempio n. 1
0
        public async Task <IActionResult> ReportsOTDetail()
        {
            AssignmentModel assig       = new AssignmentModel();
            UserModel       UserSession = HttpContext.Session.Get <UserModel>("UserSesion");

            try {
                string userId = UserSession.Id;
                int    rolId  = ConvertUserType.GetStatusUserInt(UserSession.UserType);
                var    Id     = HttpContext.Session.GetString("IdOTInformes");
                assig = await _assignmentService.GetReportByIdAsync(rolId.ToString(), Id, userId);

                List <ContactModel> FerreContacts = new List <ContactModel>();
                FerreContacts.AddRange(GetChargeInFerreyrosContact("Supervisor", assig.FerreyrosContacts));
                FerreContacts.AddRange(GetChargeInFerreyrosContact("Líder", assig.FerreyrosContacts));
                FerreContacts.AddRange(GetChargeInFerreyrosContact("Técnico", assig.FerreyrosContacts));
                assig.FerreyrosContacts = FerreContacts;
                CalculateDelayedHours(ref assig);
                if (assig.Report.Files != null)
                {
                    AddStatusFile(ref assig);
                }
                HttpContext.Session.SetString("TitleForm", "Consulta de Informes");
                HttpContext.Session.SetString("ButtonBack", "BackToReports");
            } catch (Exception) {
                return(RedirectToAction("ConsultationReports", "Reports"));
            }
            HttpContext.Session.Set <AssignmentModel>("ReporModelSupervisor", assig);
            return(View("ReportsOT", assig));
        }
Esempio n. 2
0
        public async Task <IActionResult> Login([FromBody] UserModel user)
        {
            string    status        = "0";
            string    userType      = "-1";
            UserModel userOnSession = HttpContext.Session.Get <UserModel>("UserSesion");

            try {
                if (userOnSession == null)
                {
                    UserModel userResponse = await _userService.Login(user.UserName.Trim(), user.Password.Trim());

                    if (userResponse != null)
                    {
                        status = "1";
                        HttpContext.Session.Set <UserModel>("UserSesion", userResponse);
                        HttpContext.Session.SetString("NameUser", userResponse.Name);
                        userType = ConvertUserType.GetStatusUserInt(userResponse.UserType).ToString();
                        return(Json(new { content = userResponse, Status = status, userTypeNumber = userType }));
                    }
                }
                else
                {
                    if (user.UserName.Trim() == userOnSession.UserName && user.Password.Trim() == userOnSession.Password)
                    {
                        status = "1";
                        HttpContext.Session.Set <UserModel>("UserSesion", userOnSession);
                        HttpContext.Session.SetString("NameUser", userOnSession.Name);
                        userType = ConvertUserType.GetStatusUserInt(userOnSession.UserType).ToString();
                    }
                    else
                    {
                        UserModel userResponse = await _userService.Login(user.UserName.Trim(), user.Password.Trim());

                        if (userResponse != null)
                        {
                            status = "1";
                            HttpContext.Session.Set <UserModel>("UserSesion", userResponse);
                            HttpContext.Session.SetString("NameUser", userResponse.Name);
                            userType = ConvertUserType.GetStatusUserInt(userResponse.UserType).ToString();
                            return(Json(new { content = userResponse, Status = status, userTypeNumber = userType }));
                        }
                    }
                }
            } catch (Exception) {
                HttpContext.Session.Remove("UserSesion");
                return(Json(new { content = "null" }));
            }
            return(Json(new { content = userOnSession, Status = status, userTypeNumber = userType }));
        }