Пример #1
0
        public ActionResult Create(AnimalCreateViewModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                model.Name = this.sanitizeService.Sanitize(model.Name);

                model.Story = this.sanitizeService.Sanitize(model.Story);

                model.Disease = this.sanitizeService.Sanitize(model.Disease);

                var newAnimal = AutoMapper.Mapper.Map <Animal>(model);

                newAnimal.OrganizationId = this.User.Identity.GetUserId();

                newAnimal.Organization = organizations.GetById(newAnimal.OrganizationId).FirstOrDefault();

                newAnimal.AddedOn = DateTime.UtcNow;

                var result = this.animals.AddNew(newAnimal);

                return(this.RedirectToAction("Details", "Animals", new { area = "", id = result.Id }));
            }

            return(this.View(model));
        }
Пример #2
0
        public ActionResult Create(AnimalCreateViewModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                model.Name = this.sanitizeService.Sanitize(model.Name);

                model.Story = this.sanitizeService.Sanitize(model.Story);

                model.Disease = this.sanitizeService.Sanitize(model.Disease);

                var newAnimal = AutoMapper.Mapper.Map<Animal>(model);

                newAnimal.OrganizationId = this.User.Identity.GetUserId();

                newAnimal.Organization = organizations.GetById(newAnimal.OrganizationId).FirstOrDefault();

                newAnimal.AddedOn = DateTime.UtcNow;

                var result = this.animals.AddNew(newAnimal);

                return this.RedirectToAction("Details", "Animals", new { area = "", id = result.Id});
            }

            return this.View(model);
        }