public IActionResult OnPost(string department_name, string[] designations) { if (department_name == "" || department_name == null || designations.Length == 0) { return(Page()); } var department = new DepartmentModel(); department.Name = department_name; department.Designation = new List <DesignationModel>(); foreach (var designationItem in designations) { if (designationItem != "" && designationItem != null) { department.Designation.Add(new DesignationModel { Name = designationItem }); } } _db.Departments.Add(department); _db.SaveChanges(); return(RedirectToPage("/AdminPages/Department/Departmentlist")); }
public IActionResult OnPost(string title, string long_description, bool published) { if (title != "" && title != null && long_description != "" && long_description != null) { var new_notice = new Notice(); new_notice.Published = published; new_notice.Title = title; new_notice.Description = long_description; new_notice.CreatedDate = DateTime.Now; _db.Notices.Add(new_notice); _db.SaveChanges(); return(RedirectToPage("/AdminPages/Notice/ManageNotice")); } return(Page()); }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new HRMS_DB_Context( serviceProvider.GetRequiredService <DbContextOptions <HRMS_DB_Context> >())) { //context.Users.Add(new UserModel //{ // Email = "*****@*****.**", // Name = "Career", // Password = "******", // UserName = "******", // UserType = UserType.Career //}); //context.SaveChanges(); if (context.Users.Any() && context.WeekDays.Any()) { return; } if (!context.Users.Any()) { context.Users.AddRange( new UserModel { Email = "*****@*****.**", Name = "Admin", Password = "******", RememberMe = true, UserName = "******", UserType = UserType.Admin }, new UserModel { Email = "*****@*****.**", Name = "Employee", Password = "******", RememberMe = true, UserName = "******", UserType = UserType.Employee }, new UserModel { Email = "*****@*****.**", Name = "Career", Password = "******", UserName = "******", UserType = UserType.Career } ); context.SaveChanges(); } if (!context.WeekDays.Any()) { context.WeekDays.AddRange( new WeekDayModel { Name = "Saturday", IsHoliday = false }, new WeekDayModel { Name = "Sunday", IsHoliday = false }, new WeekDayModel { Name = "Monday", IsHoliday = false }, new WeekDayModel { Name = "Tuesday", IsHoliday = false }, new WeekDayModel { Name = "Wednesday", IsHoliday = false }, new WeekDayModel { Name = "Thursday", IsHoliday = false }, new WeekDayModel { Name = "Friday", IsHoliday = true } ); context.SaveChanges(); } } }