Пример #1
0
        public ActionResult Edit(TestimonialViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var entity = Mapper.Map <TestimonialViewModel, Testimonial>(viewModel);

                    _testimonialService.Update(entity);

                    viewModel.Locales.ToList().ForEach(l =>
                    {
                        _localizedEntityService.SaveLocalizedValue(entity, e => e.Text, l.Text, l.LanguageId);
                    });

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }

            viewModel.ClientsSelectList = Mapper.Map <List <Client>, List <SelectListItem> >(_clientService.GetAll());

            return(View(viewModel));
        }
        public HttpResponseMessage Put(TestimonialUpdateRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }

            _testimonial.Update(model);

            SuccessResponse response = new SuccessResponse();

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Пример #3
0
 public void Update(IElementSettings settings, IUnitOfWork unitOfWork = null)
 {
     _testimonialService.Update(settings, unitOfWork);
 }