public ActionResult Login(Models.User dataLogin) { if (ModelState.IsValid) { UserData user = new UserData(); var res = user.login(dataLogin.username, dataLogin.password); if (res) { Models.User userLogin = user.GetByUserName(dataLogin.username); UserSection us = new UserSection(userLogin); Session.Add(Constants.USER_SECTION, us); return(RedirectToAction("Index", "HomeAdmin")); } else { ModelState.AddModelError("login", "Đăng nhập thất bại"); return(View()); } } else { ModelState.AddModelError("login", "Đăng nhập thất bại"); return(View()); } }
public List <UserSection> GetSectionsByUserId(string UserId) { List <UserSection> usersec = null; DataProvider.ExecuteCmd(GetConnection, "UserSections_selectByUserId" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@UserId", UserId); }, map : delegate(IDataReader reader, short set) { UserSection item = new UserSection(); int startingIndex = 0; item.SectionId = reader.GetSafeInt32(startingIndex++); item.EnrollmentStatusId = reader.GetSafeInt32(startingIndex++); if (usersec == null) { usersec = new List <UserSection>(); } usersec.Add(item); }); return(usersec); }
public IActionResult CreateCustomEvent([FromBody] CustomEventRequest data) { var modelStateErrors = this.ModelState.Values.SelectMany(m => m.Errors); var user = _userManager.GetUserAsync(User).Result; // Initialize database objects var course = new Course() { CourseAbbreviation = data.Name, User = user }; var section = new Section() { Course = course }; var meeting = new Meeting() { IsUnique = true, MeetingType = MeetingType.CustomEvent, Code = "A00", Days = data.Days, StartTime = new DateTime(1, 1, 1, data.StartTime.Hour, data.StartTime.Minute, 0), EndTime = new DateTime(1, 1, 1, data.EndTime.Hour, data.EndTime.Minute, 0), }; // Add back connections section.Meetings.Add(meeting); course.Sections.Add(section); var userSection = new UserSection() { Section = section, User = user, }; // Add to database _context.Courses.Add(course); _context.Sections.Add(section); _context.Meetings.Add(meeting); _context.UserSections.Add(userSection); _context.SaveChanges(); // Return response object var calendarEvents = FormatRepo.PopulateSectionEventsForBase(new List <Section> { section }, course) .Select(d => d.Value).First(); var response = new CustomEventResponse { CourseId = course.Id, SectionId = section.Id, CourseAbbreviation = course.CourseAbbreviation, CalendarEvents = calendarEvents }; return(Json(response)); }
public ActionResult Create([Bind(Include = "UserID,UserName,Password,EmpID,DateCreated,Name,Status,Department,CanEdit,CanDelete,CanAdd,CanView,RoleID,MHR,MDevice,MLeave,MDesktop,MEditAtt,MUser,MOption,MRoster,MRDailyAtt,MRLeave,MRMonthly,MRAudit,MRManualEditAtt,MREmployee,MRDetail,MRSummary,MRGraph,ViewPermanentStaff,ViewPermanentMgm,ViewContractual,ViewLocation,LocationID,MProcess")] User user) { if (db.Users.Where(aa => aa.Status == true && aa.Deleted == false).Count() >= Convert.ToInt32(GlobalVaribales.NoOfUsers)) { ModelState.AddModelError("UserName", "Your Users has exceeded from License, Please upgrade your license"); } user.CanAdd = (bool)ValueProvider.GetValue("CanAdd").ConvertTo(typeof(bool)); user.CanEdit = (bool)ValueProvider.GetValue("CanEdit").ConvertTo(typeof(bool)); user.CanDelete = (bool)ValueProvider.GetValue("CanDelete").ConvertTo(typeof(bool)); user.CanView = (bool)ValueProvider.GetValue("CanView").ConvertTo(typeof(bool)); user.MHR = (bool)ValueProvider.GetValue("MHR").ConvertTo(typeof(bool)); user.MOption = (bool)ValueProvider.GetValue("MOption").ConvertTo(typeof(bool)); user.MLeave = (bool)ValueProvider.GetValue("MLeave").ConvertTo(typeof(bool)); user.MRoster = (bool)ValueProvider.GetValue("MRoster").ConvertTo(typeof(bool)); user.MUser = (bool)ValueProvider.GetValue("MUser").ConvertTo(typeof(bool)); user.MDevice = (bool)ValueProvider.GetValue("MDevice").ConvertTo(typeof(bool)); user.MDesktop = (bool)ValueProvider.GetValue("MDesktop").ConvertTo(typeof(bool)); user.MEditAtt = (bool)ValueProvider.GetValue("MEditAtt").ConvertTo(typeof(bool)); user.MProcess = (bool)ValueProvider.GetValue("MProcess").ConvertTo(typeof(bool)); user.MRLeave = (bool)ValueProvider.GetValue("MRLeave").ConvertTo(typeof(bool)); user.MRDailyAtt = (bool)ValueProvider.GetValue("MRDailyAtt").ConvertTo(typeof(bool)); user.MRMonthly = (bool)ValueProvider.GetValue("MRMonthly").ConvertTo(typeof(bool)); user.MRAudit = (bool)ValueProvider.GetValue("MRAudit").ConvertTo(typeof(bool)); user.MRManualEditAtt = (bool)ValueProvider.GetValue("MRManualEditAtt").ConvertTo(typeof(bool)); user.MRDetail = (bool)ValueProvider.GetValue("MRDetail").ConvertTo(typeof(bool)); if (Request.Form["UserType"].ToString() == "true") { user.UserType = "Admin"; } else { user.UserType = "Restricted"; } user.DateCreated = DateTime.Today; if (ModelState.IsValid) { user.Deleted = false; db.Users.Add(user); db.SaveChanges(); if (user.UserType == "Restricted") { List <Section> secs = new List <Section>(); secs = db.Sections.ToList(); int count = Convert.ToInt32(Request.Form["uSectionCount"]); for (int i = 1; i <= count; i++) { string uSecID = "uSection" + i; string secName = Request.Form[uSecID].ToString(); int locID = secs.Where(aa => aa.SectionName == secName).FirstOrDefault().SectionID; UserSection uSec = new UserSection(); uSec.UserID = user.UserID; uSec.SecID = (short)locID; db.UserSections.Add(uSec); db.SaveChanges(); } } return(RedirectToAction("Index")); } return(View(user)); }
public List <UserSection> GetEmailList(int Id) { List <UserSection> list = null; DataProvider.ExecuteCmd(GetConnection, "dbo.UserSections_selectBySectionIdToGetEmail" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@Id", Id); }, map : delegate(IDataReader reader, short set) { UserSection item = new UserSection(); int startingIndex = 0; item.Email = reader.GetSafeString(startingIndex++); if (list == null) { list = new List <UserSection>(); } list.Add(item); } ); return(list); }
public void UserSectionTest() { // get test Assert.That(UserSection.Friends.ToString(), Is.EqualTo("friends")); Assert.That(UserSection.Subscriptions.ToString(), Is.EqualTo("subscriptions")); // parse test Assert.That(UserSection.FromJsonString("friends"), Is.EqualTo(UserSection.Friends)); Assert.That(UserSection.FromJsonString("subscriptions"), Is.EqualTo(UserSection.Subscriptions)); }
/// <summary> /// /// </summary> /// <param name="sections"></param> /// <param name="loggedUser"></param> public void AddListenerToSections(List <Section> sections, User loggedUser) { UserSection userSection = new UserSection(); userSection.User = loggedUser; foreach (var section in sections) { userSection.Section = SectionRepository.FindSectionByName(section.Name); UserSectionRepository.Add(userSection); } }
public void UserSectionTest() { // get test Assert.That(actual: UserSection.Friends.ToString(), expression: Is.EqualTo(expected: "friends")); Assert.That(actual: UserSection.Subscriptions.ToString(), expression: Is.EqualTo(expected: "subscriptions")); // parse test Assert.That(actual: UserSection.FromJsonString(response: "friends"), expression: Is.EqualTo(expected: UserSection.Friends)); Assert.That(actual: UserSection.FromJsonString(response: "subscriptions") , expression: Is.EqualTo(expected: UserSection.Subscriptions)); }
internal void LoadUserSection() { try { var contentsUser = File.ReadAllText(UserStoragePath); User = JsonConvert.DeserializeObject <UserSection>(contentsUser); } catch (FileNotFoundException) { User = UserSection.GetDefault(); SaveUserSection(); } }
public CalculatorTab(ResultantSection resultantSection) : this(resultantSection.ProjectName) { SectionModel = resultantSection; UserSection.UpdateFromSpatialModel(resultantSection.SpatialModel); if (SetConductorFromSectionModel(resultantSection.SectionConductor)) { Tension0 = resultantSection.SectionInitialTension; Temperature1 = resultantSection.SectionInitialTemperature; Temperature2 = resultantSection.SectionTargetTemperature; PresentedResultantSection.SetPresentedCollection(resultantSection.Solutions, resultantSection.Results.ToArray()); _Annalist.DisplayStatus(this.ToString(), "I200", new string[] { resultantSection.ProjectName }); } _Annalist.DisplayStatus(this.ToString(), "E200", new string[] { resultantSection.ProjectName }); }
public void RemoveCustomEvent(int courseId) { var user = _userManager.GetUserAsync(User).Result; Course course = _context.Courses .Include(c => c.Sections) .ThenInclude(s => s.Meetings) .FirstOrDefault(c => c.User == user && c.Id == courseId); Section section = course.Sections.First(); UserSection userSection = _context.UserSections.First(us => us.User == user && us.Section == section); _context.Meetings.RemoveRange(section.Meetings); _context.Sections.Remove(section); _context.UserSections.Remove(userSection); _context.Courses.Remove(course); _context.SaveChanges(); }
private static UserSection GenerateUserSection(UserSection userSection) { userSection = Fixture .Build <UserSection>() .With(us => us.UserId, userSection.UserId) .With(us => us.SurveyId, userSection.SurveyId) .With(us => us.TestId, userSection.TestId) .With(us => us.TestSectionMarkerId, userSection.TestSectionMarkerId) .With(us => us.Order, userSection.Order) .With(us => us.Started, userSection.Started) .With(us => us.Modified, userSection.Modified) .With(us => us.Completed, userSection.Completed) .With(us => us.Id, userSection.Id) .Create(); return(userSection); }
public ActionResult Index(UserLoginModel model) { if (ModelState.IsValid) { var db = new UserDb(); var result = db.LoginUser(model.Email, Encryptor.MD5Hash(model.PassWord)); if (result > 0) { var user = db.GetUserByEmail(model.Email); var userSesstion = new UserSection(); // khỏi tạo lớp để theeo sesstion userSesstion.email = user.Email; // đưa email vào user section userSesstion.IDGroup = user.IDGroup; userSesstion.Admin = user.Admin; userSesstion.IDUser = user.IDUser; userSesstion.pass = model.PassWord; userSesstion.name = user.HoTen; var ListCredential = db.GetListCredential(model.Email); // lấy danh sách quyền Session.Add(CommonContact.SESTION_CREDENTIAL, ListCredential); // đưa danh sách vào sesstion Session.Add(CommonContact.USER_SESSION, userSesstion); // lưu userSesstion vào if (result == 1) { return(RedirectToAction("Index", "Home")); } else if (result == 3) { return(Redirect("/")); } } else if (result == 0) { ModelState.AddModelError("", "Tài Khoản Không tồn tại !"); } else if (result == -1) { ModelState.AddModelError("", "Tài Khoản đang bị khóa !"); } else { ModelState.AddModelError("", "Mật khẩu không đúng !"); } } return(View("Index")); }
public ActionResult Edit(Models.User user) { UserData dataU = new UserData(); User newUser = dataU.Update(user); var section = (UserSection)Session[Constants.USER_SECTION]; if (section.UserID == newUser.ID) { UserSection us = new UserSection(newUser); Session.Add(Constants.USER_SECTION, us); } TempData["Msg"] = "Cập nhật người dung" + user.full_name + " thành công!"; return(RedirectToAction("Index")); }
// CONSTRUCTORS public CalculatorTab(string tabTitle) { ConductorBase = ConductorDataManager.Instance; _conductorAdvencedDisplayMode = false; _categoryOverview = new ObservableCollection <string>(ConductorBase.GetAvailableCategories()); _selectedCategory = _categoryOverview[0]; _conductorSearchMode = false; _searchedPhrase = ""; _conductorSearchResults = new ObservableCollection <Conductor>(); UserSection = new UserSection(); UserSection.SpatialModelUpdate += OnSpatialModelUpdate; PresentedResultantSection = new PresentedResultantSection(); Solver = new SolverViewModel(MainSettings.Instance.MainEPS, MainSettings.Instance.GravitionalAcceleration); Solver.SubscribeOn_SolverCalculationsReportSent_Event(OnSolverCalculationsReportSent); Solver.PropertyChanged += OnSolverPropertyChanged; TabTitle = tabTitle; LoadSectionModelFromCsvCommand = new CommandRelay(UserSection.LoadSectionModelFromCsv, () => true); SaveSectionModelAsCsvCommand = new CommandRelay(UserSection.SaveSectionModelAsCsv, () => true); JustAddSpan = new CommandRelay(UserSection.JustAddSpan, () => true); JustRemoveSpan = new CommandRelay(UserSection.JustRemoveSpan, CanExecute_JustRemoveSpanCommand); AddSpanBefore = new CommandRelay(UserSection.AddSpanBeforeSelectedSpan, CanExecute_BasicSectionCommand); AddSpanAfter = new CommandRelay(UserSection.AddSpanAfterSelectedSpan, CanExecute_BasicSectionCommand); ClearSpan = new CommandRelay(UserSection.ClearSelectedSpan, CanExecute_BasicSectionCommand); RemoveSpan = new CommandRelay(UserSection.RemoveSelectedSpan, CanExecute_RemoveSpanCommand); ClearAll = new CommandRelay(UserSection.ClearBackToBasicSection, CanExecute_ClearAllSectionCommand); ManuallyCheckUserSectionIntegrity = new CommandRelay(UserSection.ManualIntegrityCheck, () => true); ToggleXAxisDataInputModeCommand = new CommandRelay(ToggleXAxisDataInputMode, () => true); CloseReportCommand = new CommandRelay(UserSection.HideReport, UserSection.CanExecute_HideReport); ToggleConductorDetailsCommand = new CommandRelay(ToggleConductorDetails, () => true); }
internal void LoadUserSection(string path = null) { if (User != null) { SaveUserSection(); } var configPath = File.Exists(path) ? path : UserStoragePath; try { var contentsUser = File.ReadAllText(UserStoragePath); User = JsonConvert.DeserializeObject <UserSection>(contentsUser); User.ConfigPath = configPath; } catch (FileNotFoundException) { User = UserSection.GetDefault(); User.ConfigPath = configPath; SaveUserSection(); } }
/// <summary> /// 编辑npc表现处理 /// </summary> /// <returns>是否处理成功</returns> public bool Edit() { bool editSuccess = false; logText = new StringBuilder(); string sqlString = string.Format("SELECT SkillID FROM dic_npc_skill_caster_npc WHERE RepresentID = '{0}'", npcRepresentID); DataTable skillTable = helper.GetDataTable(conn, sqlString); if (skillTable.Rows.Count > 0) { currentSkillID2 = skillTable.Rows[0]["SkillID"].ToString(); } else { currentSkillID2 = null; } switch (userSection) { case UserSection.None: // 未保存选择 { SkillNotifyForm sForm = new SkillNotifyForm(); DialogResult dialogResult = sForm.ShowDialog(); switch (dialogResult) { case DialogResult.OK: { editSuccess = AutoCreateSkills(true); if (sForm.RecordSelection) { userSection = UserSection.AutoCreate; } break; } case DialogResult.Cancel: { if (sForm.RecordSelection) { userSection = UserSection.NotCreate; } break; } } break; } case UserSection.AutoCreate: { editSuccess = AutoCreateSkills(true); break; } case UserSection.NotCreate: { break; } } return editSuccess; }
public ActionResult Create([Bind(Include = "UserID,UserName,Password,EmpID,DateCreated,Name,Status,Department,CanEdit,CanDelete,CanAdd,CanView,RoleID,MHR,MDevice,MLeave,MDesktop,MEditAtt,MUser,MOption,MRoster,MRDailyAtt,MRLeave,MRMonthly,MRAudit,MRManualEditAtt,MREmployee,MRDetail,MRSummary,MRGraph,ViewPermanentStaff,ViewPermanentMgm,ViewContractual,ViewLocation,MProcess")] User user, string[] Location, string[] Department) { ViewBag.Location = new SelectList(db.Locations.OrderBy(s => s.LocName), "LocID", "LocName"); ViewBag.Department = new SelectList(db.Departments.OrderBy(s => s.DeptName), "DeptID", "DeptName"); if (db.Users.Where(aa => aa.Status == true && aa.Deleted == false).Count() >= Convert.ToInt32(GlobalVaribales.NoOfUsers)) { ModelState.AddModelError("UserName", "Your Users has exceeded from License, Please upgrade your license"); } user.CanAdd = (bool)ValueProvider.GetValue("CanAdd").ConvertTo(typeof(bool)); user.CanEdit = (bool)ValueProvider.GetValue("CanEdit").ConvertTo(typeof(bool)); user.CanDelete = (bool)ValueProvider.GetValue("CanDelete").ConvertTo(typeof(bool)); user.CanView = (bool)ValueProvider.GetValue("CanView").ConvertTo(typeof(bool)); user.MHR = (bool)ValueProvider.GetValue("MHR").ConvertTo(typeof(bool)); user.MOption = (bool)ValueProvider.GetValue("MOption").ConvertTo(typeof(bool)); user.MLeave = (bool)ValueProvider.GetValue("MLeave").ConvertTo(typeof(bool)); //user.MRoster = (bool)ValueProvider.GetValue("MRoster").ConvertTo(typeof(bool)); user.MUser = (bool)ValueProvider.GetValue("MUser").ConvertTo(typeof(bool)); user.MDevice = (bool)ValueProvider.GetValue("MDevice").ConvertTo(typeof(bool)); // user.MDesktop = (bool)ValueProvider.GetValue("MDesktop").ConvertTo(typeof(bool)); user.MEditAtt = (bool)ValueProvider.GetValue("MEditAtt").ConvertTo(typeof(bool)); user.MProcess = (bool)ValueProvider.GetValue("MProcess").ConvertTo(typeof(bool)); user.MRLeave = (bool)ValueProvider.GetValue("MRLeave").ConvertTo(typeof(bool)); user.MRDailyAtt = (bool)ValueProvider.GetValue("MRDailyAtt").ConvertTo(typeof(bool)); user.MRMonthly = (bool)ValueProvider.GetValue("MRMonthly").ConvertTo(typeof(bool)); //user.MRAudit = (bool)ValueProvider.GetValue("MRAudit").ConvertTo(typeof(bool)); // user.MRManualEditAtt = (bool)ValueProvider.GetValue("MRManualEditAtt").ConvertTo(typeof(bool)); user.MRDetail = (bool)ValueProvider.GetValue("MRDetail").ConvertTo(typeof(bool)); if (Request.Form["UserType"].ToString() == "true") { user.UserType = "Admin"; } else { user.UserType = "Restricted"; } user.DateCreated = DateTime.Today; if (ModelState.IsValid) { user.Deleted = false; db.Users.Add(user); db.SaveChanges(); if (user.UserType == "Restricted") { List <Section> secs = new List <Section>(); secs = db.Sections.ToList(); // int count = Convert.ToInt32(Request.Form["uSectionCount"]); //for (int i = 1; i <= count; i++) //{ //string uSecID = "uSection" + i; //string secName = Request.Form[uSecID].ToString(); //int locID = secs.Where(aa => aa.SectionName == secName).FirstOrDefault().SectionID; UserSection uLoc = new UserSection(); uLoc.UserID = user.UserID; if (Location.Count() > 0) { foreach (var item in Location) { uLoc.LocationID = Convert.ToInt16(item); uLoc.LocationOrSection = "Location"; db.UserSections.Add(uLoc); db.SaveChanges(); } } UserSection uDept = new UserSection(); uDept.UserID = user.UserID; if (Department != null && Department.Count() > 0) { foreach (var item in Department) { uDept.SectionID = Convert.ToInt16(item); uDept.LocationOrSection = "Section"; db.UserSections.Add(uDept); db.SaveChanges(); } } //} } else { UserSection us = new UserSection(); var ls = db.Locations.ToList(); var ds = db.Sections.ToList(); foreach (var item in ls) { us.LocationID = item.LocID; us.LocationOrSection = "Location"; us.UserID = user.UserID; db.UserSections.Add(us); db.SaveChanges(); } foreach (var item in ds) { us.SectionID = item.SectionID; us.LocationOrSection = "Section"; us.LocationID = null; us.UserID = user.UserID; db.UserSections.Add(us); db.SaveChanges(); } } return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Edit([Bind(Include = "UserID,UserName,Password,EmpID,DateCreated,Name,Status,Department,CanEdit,CanDelete,CanAdd,CanView,RoleID,MHR,MDevice,MLeave,MDesktop,MEditAtt,MUser,MOption,MRDailyAtt,MRLeave,MRMonthly,MRAudit,MRManualEditAtt,MREmployee,MRDetail,MRSummary,MRGraph,ViewPermanentStaff,ViewPermanentMgm,ViewContractual,ViewLocation,LocationID,MProcess")] User user, string[] Location, string[] Department) { ViewBag.Location = new SelectList(db.Locations.OrderBy(s => s.LocName), "LocID", "LocName"); ViewBag.Department = new SelectList(db.Departments.OrderBy(s => s.DeptName), "DeptID", "DeptName"); bool check = false; user.CanAdd = (bool)ValueProvider.GetValue("CanAdd").ConvertTo(typeof(bool)); user.CanEdit = (bool)ValueProvider.GetValue("CanEdit").ConvertTo(typeof(bool)); user.CanDelete = (bool)ValueProvider.GetValue("CanDelete").ConvertTo(typeof(bool)); user.CanView = (bool)ValueProvider.GetValue("CanView").ConvertTo(typeof(bool)); user.MHR = (bool)ValueProvider.GetValue("MHR").ConvertTo(typeof(bool)); user.MOption = (bool)ValueProvider.GetValue("MOption").ConvertTo(typeof(bool)); user.MLeave = (bool)ValueProvider.GetValue("MLeave").ConvertTo(typeof(bool)); // user.MRoster = (bool)ValueProvider.GetValue("MRoster").ConvertTo(typeof(bool)); user.MUser = (bool)ValueProvider.GetValue("MUser").ConvertTo(typeof(bool)); user.MDevice = (bool)ValueProvider.GetValue("MDevice").ConvertTo(typeof(bool)); user.MEditAtt = (bool)ValueProvider.GetValue("MEditAtt").ConvertTo(typeof(bool)); user.MProcess = (bool)ValueProvider.GetValue("MProcess").ConvertTo(typeof(bool)); user.MRLeave = (bool)ValueProvider.GetValue("MRLeave").ConvertTo(typeof(bool)); user.MRDailyAtt = (bool)ValueProvider.GetValue("MRDailyAtt").ConvertTo(typeof(bool)); user.MRMonthly = (bool)ValueProvider.GetValue("MRMonthly").ConvertTo(typeof(bool)); // user.MRAudit = (bool)ValueProvider.GetValue("MRAudit").ConvertTo(typeof(bool)); // user.MRManualEditAtt = (bool)ValueProvider.GetValue("MRManualEditAtt").ConvertTo(typeof(bool)); user.MRDetail = (bool)ValueProvider.GetValue("MRDetail").ConvertTo(typeof(bool)); if (Request.Form["UserType"].ToString() == "true") { user.UserType = "Admin"; } else { user.UserType = "Restricted"; } user.DateCreated = DateTime.Today; user.Deleted = false; // db.Entry(user).State = EntityState.Modified; db.Entry(user).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); //User Section int count = Convert.ToInt32(Request.Form["uSectionCount"]); List <Section> secs = new List <Section>(); List <UserSection> userLocs = db.UserSections.Where(aa => aa.UserID == user.UserID).ToList(); secs = db.Sections.ToList(); List <int> currentLocIDs = new List <int>(); foreach (var uloc in userLocs) { UserSection ul = db.UserSections.First(aa => aa.UserID == user.UserID); db.UserSections.Remove(ul); db.SaveChanges(); } userLocs = new List <UserSection>(); if (user.UserType == "Restricted") { UserSection uLoc = new UserSection(); uLoc.UserID = user.UserID; if (Location != null) { foreach (var item in Location) { uLoc.LocationID = Convert.ToInt16(item); uLoc.LocationOrSection = "Location"; uLoc.SectionID = null; db.UserSections.Add(uLoc); db.SaveChanges(); } } if (Department != null) { foreach (var item in Department) { uLoc.SectionID = Convert.ToInt16(item); uLoc.LocationID = null; uLoc.LocationOrSection = "Section"; db.UserSections.Add(uLoc); db.SaveChanges(); } } } return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "UserID,UserName,Password,EmpID,DateCreated,Name,Status,Department,CanEdit,CanDelete,CanAdd,CanView,RoleID,MHR,MDevice,MLeave,MDesktop,MEditAtt,MUser,MOption,MRDailyAtt,MRLeave,MRMonthly,MRAudit,MRManualEditAtt,MREmployee,MRDetail,MRSummary,MRGraph,ViewPermanentStaff,ViewPermanentMgm,ViewContractual,ViewLocation,LocationID,MProcess")] User user) { bool check = false; user.CanAdd = (bool)ValueProvider.GetValue("CanAdd").ConvertTo(typeof(bool)); user.CanEdit = (bool)ValueProvider.GetValue("CanEdit").ConvertTo(typeof(bool)); user.CanDelete = (bool)ValueProvider.GetValue("CanDelete").ConvertTo(typeof(bool)); user.CanView = (bool)ValueProvider.GetValue("CanView").ConvertTo(typeof(bool)); user.MHR = (bool)ValueProvider.GetValue("MHR").ConvertTo(typeof(bool)); user.MOption = (bool)ValueProvider.GetValue("MOption").ConvertTo(typeof(bool)); user.MLeave = (bool)ValueProvider.GetValue("MLeave").ConvertTo(typeof(bool)); user.MRoster = (bool)ValueProvider.GetValue("MRoster").ConvertTo(typeof(bool)); user.MUser = (bool)ValueProvider.GetValue("MUser").ConvertTo(typeof(bool)); user.MDevice = (bool)ValueProvider.GetValue("MDevice").ConvertTo(typeof(bool)); user.MDesktop = (bool)ValueProvider.GetValue("MDesktop").ConvertTo(typeof(bool)); user.MEditAtt = (bool)ValueProvider.GetValue("MEditAtt").ConvertTo(typeof(bool)); user.MProcess = (bool)ValueProvider.GetValue("MProcess").ConvertTo(typeof(bool)); user.MRLeave = (bool)ValueProvider.GetValue("MRLeave").ConvertTo(typeof(bool)); user.MRDailyAtt = (bool)ValueProvider.GetValue("MRDailyAtt").ConvertTo(typeof(bool)); user.MRMonthly = (bool)ValueProvider.GetValue("MRMonthly").ConvertTo(typeof(bool)); user.MRAudit = (bool)ValueProvider.GetValue("MRAudit").ConvertTo(typeof(bool)); user.MRManualEditAtt = (bool)ValueProvider.GetValue("MRManualEditAtt").ConvertTo(typeof(bool)); user.MRDetail = (bool)ValueProvider.GetValue("MRDetail").ConvertTo(typeof(bool)); if (Request.Form["UserType"].ToString() == "true") { user.UserType = "Admin"; } else { user.UserType = "Restricted"; } user.DateCreated = DateTime.Today; user.Deleted = false; // db.Entry(user).State = EntityState.Modified; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); //User Section int count = Convert.ToInt32(Request.Form["uSectionCount"]); List <Section> secs = new List <Section>(); List <UserSection> userLocs = db.UserSections.Where(aa => aa.UserID == user.UserID).ToList(); secs = db.Sections.ToList(); List <int> currentLocIDs = new List <int>(); foreach (var uloc in userLocs) { UserSection ul = db.UserSections.First(aa => aa.SecID == uloc.SecID); db.UserSections.Remove(ul); db.SaveChanges(); } userLocs = new List <UserSection>(); if (user.UserType == "Restricted") { for (int i = 1; i <= count; i++) { string uLocID = "uSection" + i; string LocName = Request.Form[uLocID].ToString(); int locID = secs.Where(aa => aa.SectionName == LocName).FirstOrDefault().SectionID; currentLocIDs.Add(locID); if (userLocs.Where(aa => aa.SecID == locID).Count() > 0) { } else { UserSection uloc = new UserSection(); uloc.UserID = user.UserID; uloc.SecID = (short)locID; db.UserSections.Add(uloc); userLocs.Add(uloc); db.SaveChanges(); } } } return(RedirectToAction("Index")); }
private IEnumerable <IUserSection> UserSectionBuilder(int sectionSurveyId, bool isTransition) { var sectionId = 0; var userSurvey = UserSurveys.Single(us => us.Id == sectionSurveyId); var testId = userSurvey.TestId; const int sectionCount = 10; var sectionCompleteCount = userSurvey.Completed.HasValue ? sectionCount : Fixture.Create <int>() % sectionCount; var userSections = Enumerable .Range(0, sectionCount) .Select(i => { IUserSection userSection; var isSectionGroup = i % 5 == 2; var started = i < sectionCompleteCount || (i == sectionCompleteCount - 1 && !isTransition) ? Fixture.Create <DateTime?>() : null; var modified = i < sectionCompleteCount || Fixture.Create <bool>() ? Fixture.Create <DateTime?>() : null; var completed = i < sectionCompleteCount ? Fixture.Create <DateTime?>() : null; if (isSectionGroup) { var sectionSeed = new UserSection { UserId = UserId, SurveyId = sectionSurveyId, Id = ++sectionId, TestId = testId, Order = i, Started = started, Modified = modified, Completed = completed }; userSection = GenerateSectionGroup(sectionSeed); sectionId = sectionSeed.Id.GetValueOrDefault(); } else { userSection = GenerateUserSection(new UserSection { UserId = UserId, SurveyId = sectionSurveyId, TestId = testId, Order = i, Id = ++sectionId, Started = started, Modified = modified, Completed = completed }); } return(userSection); }).ToList(); return(userSections); }
/// <summary> /// 编辑npc表现处理 /// </summary> /// <returns>是否处理成功</returns> public bool Edit() { bool editSuccess = false; logText = new StringBuilder(); switch (userSection) { case UserSection.None: // 未保存选择 { NotifyForm nForm = new NotifyForm(); DialogResult dialogResult = nForm.ShowDialog(); switch (dialogResult) { case DialogResult.OK: { InitModelScale(); editSuccess = AutoCreateActions(true, nForm.UpdateExistAnimation, true); if (nForm.RecordSelection) { userSection = UserSection.AutoCreate; updateExistAnimation = nForm.UpdateExistAnimation; } break; } case DialogResult.Cancel: { if (nForm.RecordSelection) { userSection = UserSection.NotCreate; } break; } } break; } case UserSection.AutoCreate: { InitModelScale(); editSuccess = AutoCreateActions(true, updateExistAnimation, true); break; } case UserSection.NotCreate: { break; } } return editSuccess; }