public ActionResult SaveCalendarNonWorking(CalendarNonWorkingModel model) { if (ModelState.IsValid) { var calendarNonWorking = _calendarNonWorkingRepository.GetById(model.Id); //always set IsNew to false when saving calendarNonWorking.IsNew = false; calendarNonWorking = model.ToEntity(calendarNonWorking); _calendarNonWorkingRepository.UpdateAndCommit(calendarNonWorking); return(new NullJsonResult()); } else { return(Json(new { Errors = ModelState.Errors().ToHtmlString() })); } }
public ActionResult CreateCalendarNonWorking(long calendarId) { var calendarNonWorking = new CalendarNonWorking { IsNew = true }; _calendarNonWorkingRepository.Insert(calendarNonWorking); var calendar = _calendarRepository.GetById(calendarId); calendar.CalendarNonWorkings.Add(calendarNonWorking); this._dbContext.SaveChanges(); var model = new CalendarNonWorkingModel(); model = calendarNonWorking.ToModel(); var html = this.CalendarNonWorkingPanel(model); return(Json(new { Id = calendarNonWorking.Id, Html = html })); }
public string CalendarNonWorkingPanel(CalendarNonWorkingModel model) { var html = this.RenderPartialViewToString("_CalendarNonWorkingDetails", model); return(html); }