Ejemplo n.º 1
0
        public ActionResult New(PlatformTypeViewModel platformTypeViewModel)
        {
            if (ModelState.IsValid)
            {
                var platformTypeDTO = _mapper.Map <ExtendPlatformTypeDTO>(platformTypeViewModel);

                if (!_platformTypeService.IsUniqueEnName(platformTypeDTO))
                {
                    ModelState.AddModelError("NameEn", GlobalRes.ExistPlatformTypeName);
                }

                if (platformTypeViewModel.NameRu != null)
                {
                    if (!_platformTypeService.IsUniqueRuName(platformTypeDTO))
                    {
                        ModelState.AddModelError("NameRu", GlobalRes.ExistPlatformTypeName);
                    }
                }

                if (ModelState.IsValid)
                {
                    _platformTypeService.AddNew(platformTypeDTO);

                    return(RedirectToAction("GetAll"));
                }
            }

            return(View(platformTypeViewModel));
        }