public ActionResult Edit(TutorSchedulesModel modifiedModel, string FILTER_Keyword, int?FILTER_Active) { if (ModelState.IsValid) { standardizeTime(modifiedModel); if (isExists(modifiedModel.Id, modifiedModel.Tutor_UserAccounts_Id, modifiedModel.DayOfWeek, modifiedModel.StartTime, modifiedModel.EndTime)) { ModelState.AddModelError(TutorSchedulesModel.COL_DayOfWeek.Name, "Kombinasi sudah terdaftar atau ada jam bentrok"); } else { TutorSchedulesModel originalModel = get(modifiedModel.Id); string log = string.Empty; log = Helper.append(log, originalModel.DayOfWeek, modifiedModel.DayOfWeek, TutorSchedulesModel.COL_DayOfWeek.LogDisplay); log = Helper.append(log, originalModel.StartTime, modifiedModel.StartTime, TutorSchedulesModel.COL_StartTime.LogDisplay); log = Helper.append(log, originalModel.EndTime, modifiedModel.EndTime, TutorSchedulesModel.COL_EndTime.LogDisplay); log = Helper.append(log, originalModel.Active, modifiedModel.Active, TutorSchedulesModel.COL_Active.LogDisplay); log = Helper.append(log, originalModel.Notes, modifiedModel.Notes, TutorSchedulesModel.COL_Notes.LogDisplay); if (!string.IsNullOrEmpty(log)) { update(modifiedModel, log); } return(RedirectToAction(nameof(Index), new { FILTER_Keyword = FILTER_Keyword, FILTER_Active = FILTER_Active })); } } setViewBag(FILTER_Keyword, FILTER_Active); return(View(modifiedModel)); }
public void update(TutorSchedulesModel model, string log) { LIBWebMVC.WebDBConnection.Update(db.Database, "TutorSchedules", DBConnection.getSqlParameter(TutorSchedulesModel.COL_Id.Name, model.Id), DBConnection.getSqlParameter(TutorSchedulesModel.COL_Tutor_UserAccounts_Id.Name, model.Tutor_UserAccounts_Id), DBConnection.getSqlParameter(TutorSchedulesModel.COL_DayOfWeek.Name, model.DayOfWeek), DBConnection.getSqlParameter(TutorSchedulesModel.COL_StartTime.Name, model.StartTime), DBConnection.getSqlParameter(TutorSchedulesModel.COL_EndTime.Name, model.EndTime), DBConnection.getSqlParameter(TutorSchedulesModel.COL_Active.Name, model.Active), DBConnection.getSqlParameter(TutorSchedulesModel.COL_Notes.Name, model.Notes) ); ActivityLogsController.AddEditLog(db, Session, model.Id, log); db.SaveChanges(); }
/* SEARCH *********************************************************************************************************************************************/ public ActionResult Search(string FILTER_Keyword, int?FILTER_Active) { if (!UserAccountsController.getUserAccess(Session).TutorSchedules_View) { return(RedirectToAction(nameof(HomeController.Index), "Home")); } setViewBag(FILTER_Keyword, FILTER_Active); TutorSchedulesModel model = new TutorSchedulesModel(); model.StartTime = new DateTime(1970, 1, 1, 8, 0, 0); model.EndTime = new DateTime(1970, 1, 1, 20, 0, 0); LanguagesController.setDropDownListViewBag(this); return(View(model)); }
public ActionResult Create(TutorSchedulesModel model, string FILTER_Keyword, int?FILTER_Active) { if (ModelState.IsValid) { standardizeTime(model); if (isExists(null, model.Tutor_UserAccounts_Id, model.DayOfWeek, model.StartTime, model.EndTime)) { ModelState.AddModelError(TutorSchedulesModel.COL_Tutor_UserAccounts_Id.Name, "Kombinasi sudah terdaftar atau ada jam bentrok"); } else { model.Id = Guid.NewGuid(); model.Active = true; add(model); return(RedirectToAction(nameof(Index), new { id = model.Id, FILTER_Keyword = FILTER_Keyword, FILTER_Active = FILTER_Active })); } } setViewBag(FILTER_Keyword, FILTER_Active); return(View(model)); }
/* METHODS ********************************************************************************************************************************************/ public static void standardizeTime(TutorSchedulesModel model) { model.StartTime = standardizeTime(model.StartTime); model.EndTime = standardizeTime(model.EndTime); }