public void InsertOrUpdate(USERLOGIN lang) { if (lang.USERLOGINID == default(int)) // New entity { _context.Entry(lang).State = EntityState.Added; } else // Existing entity { _context.Entry(lang).State = EntityState.Modified; } }
public void InsertOrUpdateGraph(USERLOGIN langGraph) { if (langGraph.State == DOCVIDEO.ObjectState.State.Added) { _context.UserLogins.Add(langGraph); } else { _context.UserLogins.Add(langGraph); _context.ApplyStateChanges(); } }
public static void addStudent(string holy_name, string first_name, string last_name, string email , string phone_number, string gender, string useradress, DateTime?birthday, DateTime?baptised_date, int?parish_id, string father_name, string father_phone_number, string mother_name, string mother_phone_number, string parish, string diocese, string provice, int?class_id) { using (var db = new ChurchModel()) { int count_user = db.USERLOGINs.Count(); int count_user_parish = db.USER_PARISH_ROLE.Count(); USERLOGIN new_user = new USERLOGIN { userid = count_user + 1, holy_name = holy_name, first_name = first_name, last_name = last_name, email = email, phone_number = phone_number, gender = gender, useradress = useradress, birthday = birthday, baptised_date = baptised_date, father_name = father_name, father_phone_number = father_phone_number, mother_name = mother_name, mother_phone_number = mother_phone_number, isDeleted = false, username = last_name + count_user.ToString(), userpassword = last_name + count_user.ToString() + "@123", parish = parish, diocese = diocese, province = provice, class_id = class_id }; db.USERLOGINs.Add(new_user); db.SaveChanges(); Thread.Sleep(200); db.USER_PARISH_ROLE.Add(new USER_PARISH_ROLE { USER_PARISH_ROLE_ID = count_user_parish + 1, roleid = 1, userid = new_user.userid, parishid = parish_id , isDeleted = false }); db.SaveChanges(); db.Dispose(); } }
public ActionResult Post_Login(USERLOGIN login) { using (CMSAPPEntities _context = new CMSAPPEntities()) { var userId = _context. USERLOGINs. Where(x => x.USERNAME.Equals(login.USERNAME) && x.PASSWRD.Equals(login.PASSWRD)) .SingleOrDefault(); if (userId != null) { return(Redirect("MenuList")); } else { ViewBag.Message = "Invalid Login Details."; return(RedirectToAction("Login", "Home")); } } }
public ActionResult EditTeacher(int id) { USERLOGIN user = TeacherActions.findTeacherByID(id); ViewBag.listParishes = ParishActions.listParishes(); ViewBag.StudentByID = user; ViewBag.ListClassByTeacherID = ClassActions.findListClassByTeacherID(id); var liststudent_byclassid = StudentActions.findListStudentByClassID(id); if (liststudent_byclassid == null) { ViewBag.ListStudentByClassID = null; } else { ViewBag.ListStudentByClassID = liststudent_byclassid; } return(View(ParishActions.findParishByUserID(user.userid))); }
public ActionResult EditStudent(int id) { USERLOGIN user = StudentActions.findStudentByID(id); ViewBag.listParishes = ParishActions.listParishes(); ViewBag.StudentByID = user; var listclasses = ClassActions.listClasses(); List <SelectListItem> item = new List <SelectListItem>(); int?selectedclass_id = null; foreach (var i in listclasses) { if (i.class_id == user.class_id) { selectedclass_id = i.class_id; item.Add(new SelectListItem { Text = i.class_name, Value = Convert.ToString(i.class_id), Selected = true }); } else { item.Add(new SelectListItem { Text = i.class_name, Value = Convert.ToString(i.class_id) }); } } ViewBag.listClasses = item; if (selectedclass_id == null) { ViewBag.findSelectedClassByID = null; } else { ViewBag.findSelectedClassByID = ClassActions.findListClassByID(selectedclass_id.Value); } return(View(ParishActions.findParishByUserID(user.userid))); }
public ActionResult LogOff() { UserLoginsUnitOfWork uluow = new UserLoginsUnitOfWork(); using (var repo = new UserLoginsServiceRepository(uluow)) { USERLOGIN temp = uluow.Context.UserLogins.Where(f => f.UserName == User.Identity.Name).OrderByDescending(f => f.LOGINTIME).FirstOrDefault(); if (temp != null) { temp.LOGOUTTIME = DateTime.UtcNow; temp.STATUS = "A"; temp.MODIFIEDBY = User.Identity.Name; temp.MODIFIEDON = DateTime.UtcNow; temp.State = State.Modified; repo.InsertOrUpdate(temp); uluow.Save(); } } FormsAuthentication.SignOut(); return(RedirectToAction("Index", "Home")); }
public JsonResult LogOnOuter(LogOnModel model, string returnUrl) { Session["Gridresult"] = null; try { if (ModelState.IsValid) { var data = uow.Context.UserInformations.SingleOrDefault(f => f.UserName == model.UserName); if (data == null) { return(Json(new { msg = "The user name not found" }, JsonRequestBehavior.AllowGet)); } if (data.IsApproved) { if (MembershipService.ValidateUser(model.UserName, model.Password)) { if (data != null) { if (data.USERTYPE == "P") { FormsService.SignIn(model.UserName, model.RememberMe); if (true) { UserLoginsUnitOfWork uluow = new UserLoginsUnitOfWork(); using (var repo = new UserLoginsServiceRepository(uluow)) { Session["PatientID"] = model.UserName; USERLOGIN temp = new USERLOGIN(); temp.LOGINTIME = DateTime.UtcNow; temp.DateCreated = DateTime.UtcNow; temp.CREATEDBY = model.UserName; temp.UserName = model.UserName; temp.STATUS = "A"; temp.MODIFIEDBY = model.UserName; temp.MODIFIEDON = DateTime.UtcNow; temp.State = State.Added; repo.InsertOrUpdate(temp); uluow.Save(); } } } else { return(Json(new { msg = "Account type not valid" }, JsonRequestBehavior.AllowGet)); } } } else { return(Json(new { msg = "The user name or password provided is incorrect." }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { msg = "Please Activate your account from your Email-id doccare registration message." }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { throw new CustomException("Exception:- Project: {0} \n Error Message: {1} ", ex.InnerException, new Object[] { ex.Source, ex.Message }); } return(Json(new { msg = "success" }, JsonRequestBehavior.AllowGet)); }
public ActionResult LogOn(LogOnModel model, string returnUrl) { Session["Gridresult"] = null; try { if (ModelState.IsValid) { var data = uow.Context.UserInformations.SingleOrDefault(f => f.UserName == model.UserName); if (data == null) { ModelState.AddModelError("", "The user name not found."); return(View(model)); } if (data.IsApproved) { if (MembershipService.ValidateUser(model.UserName, model.Password)) { if (data != null) { if (data.USERTYPE == "D") { FormsService.SignIn(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } else { Session["DoctorId"] = User.Identity.Name; UserLoginsUnitOfWork uluow = new UserLoginsUnitOfWork(); using (var repo = new UserLoginsServiceRepository(uluow)) { USERLOGIN temp = new USERLOGIN(); temp.LOGINTIME = DateTime.UtcNow; temp.DateCreated = DateTime.UtcNow; temp.CREATEDBY = model.UserName; temp.UserName = model.UserName; temp.STATUS = "A"; temp.MODIFIEDBY = model.UserName; temp.MODIFIEDON = DateTime.UtcNow; temp.State = State.Added; repo.InsertOrUpdate(temp); uluow.Save(); } if (data.IsfirstLogin.Trim() == "false") { return(RedirectToAction("Dashboard", "DoctorInformation")); } else { return(RedirectToAction("Welcomepage", "DoctorInformation")); } } } else if (data.USERTYPE == "P") { FormsService.SignIn(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } else { Session["PatientId"] = User.Identity.Name; UserLoginsUnitOfWork uluow = new UserLoginsUnitOfWork(); using (var repo = new UserLoginsServiceRepository(uluow)) { USERLOGIN temp = new USERLOGIN(); temp.LOGINTIME = DateTime.UtcNow; temp.DateCreated = DateTime.UtcNow; temp.CREATEDBY = model.UserName; temp.UserName = model.UserName; temp.STATUS = "A"; temp.MODIFIEDBY = model.UserName; temp.MODIFIEDON = DateTime.UtcNow; temp.State = State.Added; repo.InsertOrUpdate(temp); uluow.Save(); } if (data.IsfirstLogin.Trim() == "false") { return(RedirectToAction("Dashboard", "PatientProfile")); } else { return(RedirectToAction("Welcomepage", "PatientProfile")); } } } else if (data.USERTYPE == "A") { FormsService.SignIn(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } return(RedirectToAction("AccountAdmin", "AccountSettings")); } } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } else { ModelState.AddModelError("", "Please Activate your account from your Email-id doccare registration message."); } } } catch (Exception ex) { throw new CustomException("Exception:- Project: {0} \n Error Message: {1} ", ex.InnerException, new Object[] { ex.Source, ex.Message }); } // If we got this far, something failed, redisplay form return(View(model)); }
public TokenChange(USERLOGIN uSER, string uSERNAME, string tOKEN) { user = uSER; username = uSERNAME; token = tOKEN; }