public ActionResult AddUser(Users objUser, int roleId, int cId, int fId) { using (var objUserBal = new UsersBal()) { if (fId == 0 && !Helpers.GetLoggedInUserIsAdmin()) { fId = Helpers.GetDefaultFacilityId(); } cId = cId == 0 ? Helpers.GetSysAdminCorporateID() : cId; var userId = Helpers.GetLoggedInUserId(); var currentDateTime = Helpers.GetInvariantCultureDateTime(); if (objUser.UserID > 0) { objUser.ModifiedBy = userId; objUser.ModifiedDate = currentDateTime; } else { objUser.CreatedBy = userId; objUser.CreatedDate = currentDateTime; } objUserBal.AddUpdateUser(objUser, roleId); //start var auditlogbal = new AuditLogBal(); var auditlogObj = new AuditLog { AuditLogID = 0, UserId = userId, CreatedDate = Helpers.GetInvariantCultureDateTime(), TableName = "Users", FieldName = "Password", PrimaryKey = 0, OldValue = string.Empty, NewValue = string.Empty, CorporateId = cId, FacilityId = fId }; auditlogbal.AddUptdateAuditLog(auditlogObj); var list = objUserBal.GetUsersByCorporateIdFacilityId(cId, fId); return(PartialView(PartialViews.UsersList, list)); } }
//public ActionResult AddRoleWithUser(int userID, int roleID) //{ // var objUserRoleBal = new UserRoleBal(); // var isExist = objUserRoleBal.CheckIfExists(userID, roleID); // if (!isExist) // { // var lstUserRoles = new List<UserRole> // { // new UserRole // { // UserID = userID, // RoleID = roleID, // IsActive = true, // IsDeleted = false, // CreatedBy = Helpers.GetLoggedInUserId(), // CreatedDate = Helpers.GetInvariantCultureDateTime() // } // }; // return Json(objUserRoleBal.AddUpdateUserRole(lstUserRoles)); // } // return Json(0); //} /// <summary> /// Adds the role with user. /// </summary> /// <returns></returns> /// <summary> /// Deletes the user. /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="cId"></param> /// <param name="fId"></param> /// <returns></returns> public ActionResult DeleteUser(int userId, int cId, int fId) { var objUserBal = new UsersBal(); var objUser = objUserBal.GetUserById(userId); objUser.IsDeleted = true; objUser.DeletedBy = Helpers.GetLoggedInUserId(); objUser.DeletedDate = Helpers.GetInvariantCultureDateTime(); //To Do change it to server datetime objUser.TokenExpiryDate = null; objUser.UserToken = null; objUserBal.AddUpdateUser(objUser, 0); cId = cId == 0 ? Helpers.GetSysAdminCorporateID() : cId; if (fId == 0 && !Helpers.GetLoggedInUserIsAdmin()) { fId = Helpers.GetDefaultFacilityId(); } var list = objUserBal.GetUsersByCorporateIdFacilityId(cId, fId); return(PartialView("UserControls/_UsersList", list)); }