public ActionResult Edit(PersonViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         var person = _mappingEngine.Map<PersonViewModel, Person>(viewModel);
         _personRepository.Save(person);
         return RedirectToAction("Index", "People");
     }
     return View(viewModel);
 }
        public ActionResult Create(PersonViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var person = _mappingEngine.Map<PersonViewModel, Person>(viewModel);
                if (person != null)
                {
                    person.IsActive = true;
                    _personRepository.Save(person);
                }
                return RedirectToAction("Index");
            }

            return View(viewModel);
        }
Ejemplo n.º 3
0
 // [HttpPost]
  public ActionResult Create(PersonViewModel personViewModel)
  {
      if (personViewModel.PhotoAttachment != null)
      {
          var file = personViewModel.PhotoAttachment;
          var content=new byte[personViewModel.PhotoAttachment.ContentLength];
          file.InputStream.Read(content, 0, personViewModel.PhotoAttachment.ContentLength);
          personViewModel.Photo = content;
          personViewModel.MimeType =personViewModel.PhotoAttachment.ContentType;
      }
      if (ModelState.IsValid)
      {
          var person = _mapper.Map<PersonViewModel, Person>(personViewModel);
          _personRepository.Save(person);
          return RedirectToAction("Index");
      }
      return View(personViewModel);
  }