Beispiel #1
0
        public async Task <IActionResult> ChooseNewNumberForBeehive(int id, int selectedApiaryId)
        {
            var currentUser = await this.userManager.GetUserAsync(this.User);

            var inputModel = new ChooseNewNumberForBeehiveInputModel
            {
                BeehiveId           = id,
                BeehiveNumber       = this.beehiveService.GetBeehiveNumberById(id),
                BeehiveApiaryId     = selectedApiaryId,
                BeehiveApiaryName   = this.apiaryService.GetApiaryNameByApiaryId(selectedApiaryId),
                BeehiveApiaryNumber = this.apiaryService.GetApiaryNumberByApiaryId(selectedApiaryId),
            };

            return(this.View(inputModel));
        }
Beispiel #2
0
        public async Task <IActionResult> ChooseNewNumberForBeehive(int id, ChooseNewNumberForBeehiveInputModel inputModel)
        {
            var currentUser = await this.userManager.GetUserAsync(this.User);

            if (!this.ModelState.IsValid)
            {
                return(this.View(inputModel));
            }

            await this.beehiveService.UpdateBeehiveNumberAndApiary(id, inputModel.BeehiveNumber, inputModel.BeehiveApiaryId);

            var messageText = $"Успешно преместихте кошер №{inputModel.BeehiveNumber}!";

            this.TempData[GlobalConstants.SuccessMessage] = messageText;
            return(this.RedirectToAction(nameof(this.ById), new { id = id }));
        }