Ejemplo n.º 1
0
        public async Task <IActionResult> Create(CreateApiaryInputModel inputModel, string returnUrl)
        {
            if (inputModel.IsRegistered && inputModel.CityCode != null)
            {
                var postcode = inputModel.CityCode.Split('-')[0];
                if (!this.forecastService.ValidateCityPostcode(postcode, this.configuration["OpenWeatherMap:ApiId"]))
                {
                    this.ModelState.AddModelError(string.Empty, "Не съществува населено място с въведения пощенски код.");
                }
            }

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

            var currentUser = await this.userManager.GetUserAsync(this.User);

            var apiaryId =
                await this.apiaryService.CreateUserApiaryAsync(
                    currentUser.Id,
                    inputModel.Number,
                    inputModel.Name,
                    inputModel.ApiaryType,
                    inputModel.Adress,
                    inputModel.IsRegistered,
                    inputModel.IsClosed,
                    inputModel.OpeningDate,
                    inputModel.ClosingDate);

            this.TempData[GlobalConstants.SuccessMessage] = $"Успешно създаден пчелин!";

            return(this.RedirectToAction(nameof(this.ById), new { id = apiaryId }));
        }
Ejemplo n.º 2
0
        public IActionResult Create(bool selectMovable = false)
        {
            var inputModel = new CreateApiaryInputModel();

            inputModel.IsRegistered = true;

            if (selectMovable)
            {
                inputModel.ApiaryType = ApiaryType.Movable;
            }

            return(this.View(inputModel));
        }