public ActionResult Login(LoginViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    DbfunctionUtility dbfunction = new DbfunctionUtility(_appSettings);
                    DataSet           ds         = dbfunction.GetDataset("select * from users  where username ='******' and Password ='******'");

                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        ViewBag.ErrorMessage = "Incorrect username or password";
                    }
                    else
                    {
                        CommanUtility commanUtility = new CommanUtility(_appSettings);
                        var           userMenus     = commanUtility.GetUserMenus(Convert.ToString(ds.Tables[0].Rows[0]["RoleId"]));
                        HttpContext.Session.SetString("UserMenus", JsonConvert.SerializeObject(userMenus));
                        HttpContext.Session.SetString("UserId", Convert.ToString(ds.Tables[0].Rows[0]["Userid"]));
                        HttpContext.Session.SetString("RoleId", Convert.ToString(ds.Tables[0].Rows[0]["RoleId"]));
                        HttpContext.Session.SetString("Username", model.Username);
                        return(RedirectToAction("Dashboard", "Home"));
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult ResetPassword(string email)
        {
            ResetPasswordViewModel model          = new ResetPasswordViewModel();
            CommanUtility          _commanUtility = new CommanUtility(_appSettings);

            try
            {
                model.Email = _commanUtility.DecryptString(email);
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = "Email not found ";
            }

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult ForgotPassword(ForgetPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                EmailUtility  _emaUtility    = new EmailUtility(_appSettings, _emailSettings);
                CommanUtility _commanUtility = new CommanUtility(_appSettings);
                var           encEmail       = _commanUtility.EncryptString(model.Email);
                string        emailBody      = @"<p>Please click on  following link to reset password</p>
                                    <br />
                                  <p><a href='" + _appSettings.Value.WebBaseURL + "/Account/ResetPassword?email=" + encEmail + "'>" + _appSettings.Value.WebBaseURL + "/ResetPassword?email=" + encEmail + "</a></p>";


                _emaUtility.SendEmail("", "Reset Password link for employee test", emailBody, model.Email.Split(","));
            }
            else
            {
            }

            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult Login(LoginViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    DbfunctionUtility dbfunction = new DbfunctionUtility(_appSettings);
                    DataSet           ds         = dbfunction.GetDataset("select * from users join roles on users.roleid = roles.roleid  where username ='******' and Password ='******'");

                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        ViewBag.ErrorMessage = "Incorrect username or password";
                    }
                    else
                    {
                        CommanUtility commanUtility = new CommanUtility(_appSettings);
                        var           userMenus     = commanUtility.GetUserMenus(Convert.ToString(ds.Tables[0].Rows[0]["RoleId"]));
                        HttpContext.Session.SetString("UserMenus", JsonConvert.SerializeObject(userMenus));
                        HttpContext.Session.SetString("UserId", Convert.ToString(ds.Tables[0].Rows[0]["Userid"]));
                        HttpContext.Session.SetString("RoleName", Convert.ToString(ds.Tables[0].Rows[0]["RoleName"]));
                        HttpContext.Session.SetString("HrGroupId", Convert.ToString(ds.Tables[0].Rows[0]["HrGroupId"]));
                        HttpContext.Session.SetString("Username", model.Username);
                        if (Convert.ToString(ds.Tables[0].Rows[0]["RoleName"]) != "CareGiver")
                        {
                            return(RedirectToAction("List", "CareGiver"));
                        }
                        else
                        {
                            var TestList  = _dbContext.tbl_Tests.Where(w => w.SeasonId == 1).ToList();
                            var testCount = 0;

                            foreach (var test in TestList)
                            {
                                var totalVideos   = _dbContext.tbl_Testvideos.Count();
                                var watchedVideos = (from userVideo in _dbContext.tbl_AttendentTestVideos
                                                     join testVideo in _dbContext.tbl_Testvideos
                                                     on userVideo.VideoId equals testVideo.Id
                                                     where userVideo.UserId == Convert.ToInt32(ds.Tables[0].Rows[0]["Userid"]) &&
                                                     testVideo.TestId == test.Id && userVideo.IsCompleted == true
                                                     select testVideo.Id).Count();

                                if (totalVideos == watchedVideos)
                                {
                                    testCount++;
                                }
                            }

                            if (testCount > 0)
                            {
                                HttpContext.Session.SetString("ShowTest", "True");
                                return(RedirectToAction("Exam", "Attendant"));
                            }
                            else
                            {
                                HttpContext.Session.SetString("ShowTest", "False");
                                HttpContext.Session.SetString("Username", model.Username);
                                return(RedirectToAction("Videos", "Test"));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(View(model));
        }
        public IActionResult CareGiversTest(string id)
        {
            var globalSettings = new GlobalSettings
            {
                ColorMode   = ColorMode.Color,
                Orientation = Orientation.Landscape,
                PaperSize   = PaperKind.A4Plus,
                Margins     = new MarginSettings {
                    Top = 10
                },
                DocumentTitle = "CareGiver Test  Report",
                // Out = filePath
            };

            var userIdList = id.Split(",").ToList();

            userIdList = userIdList.Select(s => "/" + s + "/").ToList();
            var         userIds      = String.Join(',', userIdList);
            TestUtility _testUtility = new TestUtility(_appSettings, _dbContext);
            TemplateGeneratorUtility _templateGeneratorUtility = new TemplateGeneratorUtility(_appSettings, _dbContext);

            DbfunctionUtility dbfunction     = new DbfunctionUtility(_appSettings);
            DataSet           ds             = dbfunction.GetDataset(@"call get_careGiverTest('" + userIds + "')");
            CommanUtility     _commanUtility = new CommanUtility(_appSettings);
            var list = (from row in ds.Tables[0].AsEnumerable()
                        select new PrintPDFViewModel
            {
                FirstName = Convert.ToString(row["FirstName"]),
                MiddleName = Convert.ToString(row["MiddleName"]),
                LastName = Convert.ToString(row["LastName"]),
                UserId = Convert.ToInt32(row["UserId"]),
                Question = Convert.ToString(row["Question"]),
                Choice1 = Convert.ToString(row["Choice1"]),
                Choice2 = Convert.ToString(row["Choice2"]),
                Choice3 = Convert.ToString(row["Choice3"]),
                Choice4 = Convert.ToString(row["Choice4"]),
                Choice5 = Convert.ToString(row["Choice5"]),
                Answer = Convert.ToInt32(row["Answer"]),
                TestId = Convert.ToInt32(row["testId"]),
                TestName = Convert.ToString(row["Name"]),
                UserAnswer = Convert.ToInt16(row["UserSelected"]),
                EndDate = Convert.ToDateTime(row["EndDate"]),
                Pass = Convert.ToInt32(row["status"]),
            }).ToList();


            var objectSettings = new ObjectSettings
            {
                PagesCount     = true,
                HtmlContent    = _templateGeneratorUtility.GetHTMLStringForAll(list),
                WebSettings    = { DefaultEncoding = "utf-8", UserStyleSheet = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "css", "pdfstyles.css") },
                HeaderSettings = { FontName = "Arial", FontSize = 9, Center = "StandardPrecautions HIPPA Emergency Preparedness Home Safety", Left = "Print Date: " + DateTime.Now.ToString("MM/dd/yyyy") + "", Right = "Page [page] of [toPage]", Line = false },
                FooterSettings = { FontName = "Arial", FontSize = 9, Line = false, Center = "" },
            };

            var pdf = new HtmlToPdfDocument()
            {
                GlobalSettings = globalSettings,
                Objects        = { objectSettings }
            };
            var file = _converter.Convert(pdf);

            return(File(file, "application/pdf", "CareGiverTestReport.pdf"));
        }
        public async Task <IActionResult> LoadTable([FromBody] JqueryDataTablesParameters param)
        {
            try
            {
                HttpContext.Session.SetString(nameof(JqueryDataTablesParameters), JsonSerializer.Serialize(param));
                IQueryable <EmployeeViewModel_datatable> employees;
                string            queryDef = "call get_careGiverList()";
                DbfunctionUtility dbfunction = new DbfunctionUtility(_appSettings);
                CommanUtility     _commanUtility = new CommanUtility(_appSettings);
                DateTime          startDate = new DateTime(); DateTime endDate = new DateTime(); int i = 0; bool isDateFilter = false;
                DataSet           ds = new DataSet();

                foreach (var column in param.AdditionalValues)
                {
                    if (Convert.ToString(column) != "")
                    {
                        isDateFilter = true;
                        var dateParts = column.Split("/");

                        // var date = dateParts[1] + "/" + dateParts[0] + "/" + dateParts[2];
                        if (i == 0)
                        {
                            DateTime.TryParse(column, out startDate);
                        }
                        else if (i == 1)
                        {
                            DateTime.TryParse(column, out endDate);
                        }
                    }
                    i++;
                }

                if (isDateFilter == false)
                {
                    ds = dbfunction.GetDataset(@"call get_careGiverList()");
                }
                else
                {
                    ds = dbfunction.GetDataset(@"call get_careGiverListByDate('" + startDate.ToString("yyyy/MM/dd") + "','" + endDate.ToString("yyyy/MM/dd") + "') ");
                }

                employees = (from row in ds.Tables[0].AsEnumerable()
                             select new EmployeeViewModel_datatable
                {
                    EmployeeId = Convert.ToInt32(row["Id"]),
                    FirstName = Convert.ToString(row["FirstName"]),
                    MiddleName = Convert.ToString(row["MiddleName"]),
                    LastName = Convert.ToString(row["LastName"]),
                    Email = Convert.ToString(row["Email"]),
                    EmployeeNo = Convert.ToString(row["EmployeeNo"]),
                    UserId = Convert.ToInt32(row["UserId"]),
                    HrGroupName = Convert.ToString(row["HrGroup"]),
                    HrGroupId = Convert.ToInt32(row["HrGroupId"]),
                    PassedTest = Convert.ToInt32(row["PassedTest"]),
                    Totaltest = Convert.ToInt32(row["total_tests_1"]),
                    VideoDuration = Convert.ToString(row["VideoDuration"]) == "" ? (Decimal?)null : Convert.ToDecimal(row["VideoDuration"]),
                    ExamDate = Convert.ToString(row["ExamDate"]) == "" ? (DateTime?)null : Convert.ToDateTime(row["ExamDate"]),
                    ValidEmail = _commanUtility.CheckValidEmail(Convert.ToString(row["Email"]))
                }).AsQueryable();

                if (_rolename.ToLower() == "hr")
                {
                    employees = employees.Where(w => _HrGroupId.Contains("/" + w.HrGroupId.ToString() + "/")).AsQueryable();
                }


                employees = SearchOptionsProcessor <EmployeeViewModel_datatable, EmployeeViewModel_datatable> .Apply(employees, param.Columns);

                employees = SortOptionsProcessor <EmployeeViewModel_datatable, EmployeeViewModel_datatable> .Apply(employees, param);

                var size = employees.Count();


                if (Convert.ToString(param.Search?.Value) != "")
                {
                    var serchValue = param.Search?.Value.ToLower();
                    employees = employees.Where(w =>
                                                (w.FirstName.ToLower().Contains(serchValue) ? true :
                                                 (w.MiddleName.ToLower().Contains(serchValue) ? true :
                                                  ((w.LastName.ToLower().Contains(serchValue) ? true :
                                                    ((w.EmployeeNo.ToLower().Contains(serchValue) ? true :
                                                      ((w.Email.ToLower().Contains(serchValue) ? true :
                                                        ((w.HrGroupName.ToLower().Contains(serchValue) ? true : false))))))))
                                                 )));
                }

                var items = employees
                            .Skip((param.Start / param.Length) * param.Length)
                            .Take(param.Length)
                            .ProjectTo <EmployeeViewModel_datatable>(_mappingConfiguration)
                            .ToArray();


                var result = new JqueryDataTablesPagedResults <EmployeeViewModel_datatable>
                {
                    Items     = items,
                    TotalSize = size
                };

                return(new JsonResult(new JqueryDataTablesResult <EmployeeViewModel_datatable>
                {
                    Draw = param.Draw,
                    Data = result.Items,
                    RecordsFiltered = result.TotalSize,
                    RecordsTotal = result.TotalSize
                }));
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
                return(new JsonResult(new { error = "Internal Server Error" }));
            }
        }