Exemplo n.º 1
0
        public async Task<IActionResult> Edit(int id, EditHarvestInputModel inputModel)
        {
            inputModel.Quantity = Convert.ToDouble(inputModel.QuantityText);

            await this.harvestService.EditHarvestAsync(id, inputModel);

            var beehiveId = this.beehiveService.GetBeehiveIdByHarvesId(id);

            this.TempData[GlobalConstants.SuccessMessage] = $"Успешно редактиран добив!";
            return this.RedirectToAction(nameof(this.AllByBeehiveId), new { id = beehiveId });
        }
Exemplo n.º 2
0
        public async Task <int> EditHarvestAsync(int harvestId, EditHarvestInputModel inputModel)
        {
            var harvest = this.harvestRepository
                          .All()
                          .FirstOrDefault(h => h.Id == harvestId);

            harvest.HarvestName        = inputModel.HarvestName;
            harvest.DateOfHarves       = inputModel.DateOfHarves;
            harvest.Note               = inputModel.Note;
            harvest.HarvestProductType = inputModel.HarvestProductType;
            harvest.HoneyType          = inputModel.HoneyType;
            harvest.Quantity           = Convert.ToDouble(inputModel.QuantityText);
            harvest.Unit               = inputModel.Unit;

            await this.harvestRepository.SaveChangesAsync();

            return(harvestId);
        }