public async Task <IActionResult> Edit(ScheduleDayEditViewModel inputModel)
        {
            if (this.ModelState.IsValid)
            {
                var scheduleId = await this.scheduleDaysServices.UpdateAsync(inputModel, this.Creator());

                return(this.RedirectToAction("Index", "ScheduleDays", new { id = scheduleId }));
            }

            return(this.View(inputModel));
        }
Exemplo n.º 2
0
        public async Task <int> UpdateAsync(ScheduleDayEditViewModel model, string modifier)
        {
            var scheduleDay = this.scheduleDayRepository
                              .All()
                              .FirstOrDefault(x => x.Id == model.Id);

            if (scheduleDay != null)
            {
                scheduleDay.Name          = model.Name;
                scheduleDay.WorkingMode   = model.WorkingMode;
                scheduleDay.Begins        = model.Begins.Length > 5 ? null : model.Begins;
                scheduleDay.Duration      = model.Duration == 0 ? null : model.Duration;
                scheduleDay.IncludingRest = model.IncludingRest == 0 ? null : model.IncludingRest;
                scheduleDay.ModifiedFrom  = modifier;
            }

            await this.scheduleDayRepository.SaveChangesAsync();

            return(model.ScheduleId);
        }