Ejemplo n.º 1
0
        public async Task <ActionResult> Create(CreateRangeInput input)
        {
            if (ModelState.IsValid)
            {
                await _rangeAppService.CreateRange(input);

                return(RedirectToAction("Index"));
            }
            else
            {
                var divisions = _divisinAppService.GetDivisions().Select(c => new SelectListItem {
                    Value = c.Id.ToString(), Text = c.Name
                });
                ViewBag.DivisionId = divisions;
                return(View(input));
            }
        }
Ejemplo n.º 2
0
        public async Task CreateRange(CreateRangeInput input)
        {
            //var Range = input.MapTo<Range>();

            var range = new Range
            {
                Name       = input.Name,
                DivisionId = input.DivisionId
            };

            var existingRange = _rangeRepository.FirstOrDefault(p => p.Name == input.Name);

            if (existingRange == null)
            {
                await _rangeRepository.InsertAsync(range);
            }
            else
            {
                throw new UserFriendlyException("There is already a Range with given name");
            }
        }