internal override Task <object> GetInfo() { object result = null; var item = Item; result = new WorkingHourModel { ID = item.ID, Name = item.Name, Price = item.Price }; return(Task.FromResult(result)); }
protected override async Task SaveAsync() { try { var name = View.NameWorkingHour; var price = View.Price; if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(null, "Вы не ввели наименование нормочаса!"); } using (var context = new DbSSContext()) { if (Identifier != null) { await context.WorkingHour.Where(w => w.ID == Identifier).UpdateAsync(w => new WorkingHourModel { Name = name, Price = price }); } else { WorkingHourModel insertWorkingHourInfo = new WorkingHourModel { ID = ConsistentGuid.CreateGuid(), Name = name, Price = price }; context.WorkingHour.Add(insertWorkingHourInfo); await context.SaveChangesAsync(); Identifier = insertWorkingHourInfo.ID; } } View.Close(); } catch (Exception ex) { ShowError(ex.Message); } }
protected override void SubscribeEvent() { View.Loading += View_Loading; View.Save += async() => await SaveAsync(); View.SelectionNomenclature += () => { JournalsForm journal = new JournalsForm(); JournalsPresenter <Nomenclature> presenter = new JournalsPresenter <Nomenclature>(journal, new NomenclatureJournal(journal.Grid, TypeNomernclature.Work)); journal.ShowDialog(); if (presenter.Info != null) { NomenclatureModel nomenclature = (NomenclatureModel)presenter.Info; _numberNomenclature = nomenclature.Number; View.Nomenclature = nomenclature.ShortName; View.NormOfTime = nomenclature.Price; } }; View.SelectionWorkingHour += () => { JournalsForm journal = new JournalsForm(); JournalsPresenter <WorkingHour> presenter = new JournalsPresenter <WorkingHour>(journal, new WorkingHourJournal(journal.Grid)); journal.ShowDialog(); if (presenter.Info != null) { WorkingHourModel workingHour = (WorkingHourModel)presenter.Info; _workingHourID = workingHour.ID; _price = workingHour.Price; View.NameWorkingHour = workingHour.Name; View.PriceWorkingHour = GetPriceText(workingHour.Price); CalculateSum(); } }; View.CalculateSum += CalculateSum; }
public IActionResult UpdateWorkingHours([FromRoute] string id, [FromBody] WorkingHourModel model) { _workingScheduleService.UpdateWorkingHour(id.ParseGuid(), model.Hours); return(Success()); }