/* CREATE *********************************************************************************************************************************************/ // GET: StudentSchedules/Create public ActionResult Create(string FILTER_Keyword, string FILTER_UserAccounts_Name, string FILTER_Custom, DayOfWeekEnum?DayOfWeek, string StartTime, Guid?Id, string Name) { if (!UserAccountsController.getUserAccess(Session).StudentSchedules_View) { return(RedirectToAction(nameof(HomeController.Index), "Home")); } setViewBag(FILTER_Keyword, FILTER_UserAccounts_Name, FILTER_Custom); StudentSchedulesModel model = new StudentSchedulesModel(); if (Id != null) { model.Tutor_UserAccounts_Id = (Guid)Id; model.Tutor_UserAccounts_Name = Name; } if (DayOfWeek != null) { model.DayOfWeek = (DayOfWeekEnum)DayOfWeek; } if (!string.IsNullOrEmpty(StartTime)) { model.StartTime = Util.standardizeTimeToIgnoreDate(StartTime); model.EndTime = model.StartTime.AddHours(1); } return(View(model)); }
/* METHODS ********************************************************************************************************************************************/ public static void parseLessonLocation(ref StudentSchedulesModel model) { if (model.LessonLocationRadioButton == LOCATION_ONSITE) { model.LessonLocation = LOCATION_ONSITE; } else if (model.LessonLocationRadioButton == LOCATION_ONLINE) { model.LessonLocation = LOCATION_ONLINE; } else if (model.LessonLocationRadioButton == null) { model.LessonLocation = null; } }
public void update(StudentSchedulesModel model, string log) { LIBWebMVC.WebDBConnection.Update(db.Database, "StudentSchedules", DBConnection.getSqlParameter(StudentSchedulesModel.COL_Id.Name, model.Id), DBConnection.getSqlParameter(StudentSchedulesModel.COL_Tutor_UserAccounts_Id.Name, model.Tutor_UserAccounts_Id), DBConnection.getSqlParameter(StudentSchedulesModel.COL_Student_UserAccounts_Id.Name, model.Student_UserAccounts_Id), DBConnection.getSqlParameter(StudentSchedulesModel.COL_SaleInvoiceItems_Id.Name, model.SaleInvoiceItems_Id), DBConnection.getSqlParameter(StudentSchedulesModel.COL_DayOfWeek.Name, model.DayOfWeek), DBConnection.getSqlParameter(StudentSchedulesModel.COL_StartTime.Name, model.StartTime), DBConnection.getSqlParameter(StudentSchedulesModel.COL_EndTime.Name, model.EndTime), DBConnection.getSqlParameter(StudentSchedulesModel.COL_LessonLocation.Name, model.LessonLocation), DBConnection.getSqlParameter(StudentSchedulesModel.COL_Notes.Name, model.Notes) ); ActivityLogsController.AddEditLog(db, Session, model.Id, log); db.SaveChanges(); }
public ActionResult Create(StudentSchedulesModel model, string FILTER_Keyword, string FILTER_UserAccounts_Name, string FILTER_Custom) { if (ModelState.IsValid) { parseLessonLocation(ref model); standardizeTimeToIgnoreDate(model); if (isExists(null, model.Tutor_UserAccounts_Id, model.Student_UserAccounts_Id, model.DayOfWeek, model.StartTime, model.EndTime)) { ModelState.AddModelError(StudentSchedulesModel.COL_DayOfWeek.Name, "Ada bentrok waktu dengan jadwal murid atau tutor"); } else { add(model); return(RedirectToAction(nameof(Index), new { id = model.Id, FILTER_Keyword = FILTER_Keyword, FILTER_UserAccounts_Name = FILTER_UserAccounts_Name, FILTER_Custom = FILTER_UserAccounts_Name })); } } setViewBag(FILTER_Keyword, FILTER_UserAccounts_Name, FILTER_Custom); return(View(model)); }
/* EDIT ***********************************************************************************************************************************************/ // GET: StudentSchedules/Edit/{id} public ActionResult Edit(Guid?id, string FILTER_Keyword, string FILTER_UserAccounts_Name, string FILTER_Custom) { if (!UserAccountsController.getUserAccess(Session).StudentSchedules_View) { return(RedirectToAction(nameof(HomeController.Index), "Home")); } if (id == null) { return(RedirectToAction(nameof(Index))); } setViewBag(FILTER_Keyword, FILTER_UserAccounts_Name, FILTER_Custom); StudentSchedulesModel model = get((Guid)id); if (model.SessionHours_Remaining == 0) { model.SaleInvoiceItems_Id = Guid.Empty; ModelState.AddModelError(StudentSchedulesModel.COL_SaleInvoiceItems_Id.Name, "Paket sebelumnya sudah tidak memiliki sisa jam"); } return(View(model)); }
public ActionResult Edit(StudentSchedulesModel modifiedModel, string FILTER_Keyword, string FILTER_UserAccounts_Name, string FILTER_Custom) { if (ModelState.IsValid) { standardizeTimeToIgnoreDate(modifiedModel); if (isExists(modifiedModel.Id, modifiedModel.Tutor_UserAccounts_Id, modifiedModel.Student_UserAccounts_Id, modifiedModel.DayOfWeek, modifiedModel.StartTime, modifiedModel.EndTime)) { ModelState.AddModelError(StudentSchedulesModel.COL_DayOfWeek.Name, "Kombinasi sudah terdaftar atau ada jam bentrok"); } else { StudentSchedulesModel originalModel = get(modifiedModel.Id); parseLessonLocation(ref modifiedModel); string log = string.Empty; log = Helper.append <UserAccountsModel>(log, originalModel.Tutor_UserAccounts_Id, modifiedModel.Tutor_UserAccounts_Id, StudentSchedulesModel.COL_Tutor_UserAccounts_Id.LogDisplay); log = Helper.append <UserAccountsModel>(log, originalModel.Student_UserAccounts_Id, modifiedModel.Student_UserAccounts_Id, StudentSchedulesModel.COL_Student_UserAccounts_Id.LogDisplay); log = Helper.append <SaleInvoiceItemsModel>(log, originalModel.SaleInvoiceItems_Id, modifiedModel.SaleInvoiceItems_Id, StudentSchedulesModel.COL_SaleInvoiceItems_Id.LogDisplay); log = Helper.append(log, originalModel.DayOfWeek, modifiedModel.DayOfWeek, StudentSchedulesModel.COL_DayOfWeek.LogDisplay); log = Helper.append(log, originalModel.StartTime, modifiedModel.StartTime, StudentSchedulesModel.COL_StartTime.LogDisplay); log = Helper.append(log, originalModel.EndTime, modifiedModel.EndTime, StudentSchedulesModel.COL_EndTime.LogDisplay); log = Helper.append(log, originalModel.LessonLocation, modifiedModel.LessonLocation, StudentSchedulesModel.COL_LessonLocation.LogDisplay); log = Helper.append(log, originalModel.Active, modifiedModel.Active, StudentSchedulesModel.COL_Active.LogDisplay); log = Helper.append(log, originalModel.Notes, modifiedModel.Notes, StudentSchedulesModel.COL_Notes.LogDisplay); if (!string.IsNullOrEmpty(log)) { update(modifiedModel, log); } return(RedirectToAction(nameof(Index), new { FILTER_Keyword = FILTER_Keyword, FILTER_UserAccounts_Name = FILTER_UserAccounts_Name, FILTER_Custom = FILTER_UserAccounts_Name })); } } setViewBag(FILTER_Keyword, FILTER_UserAccounts_Name, FILTER_Custom); return(View(modifiedModel)); }
public static void standardizeTimeToIgnoreDate(StudentSchedulesModel model) { model.StartTime = Util.standardizeTimeToIgnoreDate(model.StartTime); model.EndTime = Util.standardizeTimeToIgnoreDate(model.EndTime); }