Ejemplo n.º 1
0
        public async Task <IActionResult> Save(int id, ByBeehiveIdBeehiveDiaryViewModel inputModel)
        {
            var currentUser = await this.userManager.GetUserAsync(this.User);

            var apiaryId = (int)default;

            if (this.beehiveService.HasDiary(id))
            {
                apiaryId = await this.beehiveDiaryService.SaveAsync(id, inputModel.Content, currentUser.Id);
            }
            else
            {
                apiaryId = await this.beehiveDiaryService.CreateAsync(id, inputModel.Content, currentUser.Id);
            }

            this.TempData[GlobalConstants.SuccessMessage] = $"Успешно запазихте дневника на кошера!";

            return(this.RedirectToAction(nameof(this.ByBeehiveId), new { id = apiaryId }));
        }
Ejemplo n.º 2
0
        public IActionResult ByBeehiveId(int id)
        {
            var viewModel = this.beehiveDiaryService.GetBeehiveDiaryByBeehiveId <ByBeehiveIdBeehiveDiaryViewModel>(id);

            if (viewModel == null)
            {
                viewModel = new ByBeehiveIdBeehiveDiaryViewModel();

                var beehive = this.beehiveService.GetBeehiveById <BeehiveDataModel>(id);

                viewModel.BeehiveId           = id;
                viewModel.BeehiveApiaryNumber = beehive.Apiary.Number;
                viewModel.BeehiveApiaryName   = beehive.Apiary.Name;
                viewModel.BeehiveNumber       = beehive.Number;
                viewModel.BeehiveApiaryId     = beehive.Apiary.Id;
            }

            this.TempData.Keep();

            return(this.View(viewModel));
        }