Exemplo n.º 1
0
 public ActionResult Create(Guid contactId)
 {
     var contactInfoDetailDto = new ContactInfoDetailDto
     {
         ContactId = contactId
     };
     return View(contactInfoDetailDto);
 }
Exemplo n.º 2
0
        public void CreateContactInfo(ContactInfoDetailDto contactInfoDetailDto)
        {
            using (var uow = unitOfWorkFactory.GetUnitOfWork())
            {
                var contactInfo = Mapper.Map<ContactInfo>(contactInfoDetailDto);
             //   ValidateAndThrow(contactInfo);

                uow.Repository.Add(contactInfo);
                uow.Commit();
            }
        }
 public HttpResponseMessage Update(ContactInfoDetailDto contact)
 {
     try
     {
         this.contactApplicationService.UpdateContactInfo(contact);
         return Request.CreateResponse(HttpStatusCode.OK, contact);
     }
     catch (ValidationException ex)
     {
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message);
     }
 }
Exemplo n.º 4
0
 public HttpResponseMessage Create(ContactInfoDetailDto contact)
 {
     try
     {
         _contactCrudService.CreateContactInfo(contact);
         return Request.CreateResponse(HttpStatusCode.Created, contact);
     }
     catch (ValidationException ex)
     {
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message);
     }
 }
Exemplo n.º 5
0
        public ActionResult Create(ContactInfoDetailDto contactInfoDetailDto)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _contactCrudService.CreateContactInfo(contactInfoDetailDto);
                    return RedirectToAction("Edit", "Contacts", new { id = contactInfoDetailDto.ContactId });
                }
                catch (ValidationException ex)
                {
                    ModelState.AddValidationErrors(ex);
                }
            }

            return View(contactInfoDetailDto);
        }
Exemplo n.º 6
0
        public void CreateContactInfo(ContactInfoDetailDto contactInfoDetailDto)
        {
            using (var uow = GetUnitOfWork())
            {
                var contactInfo = GetMapper().Map<ContactInfo, ContactInfoDetailDto>(contactInfoDetailDto);
                var validator = GetValidationFactory().GetValidatorFor<ContactInfo>();
                if (validator != null)
                {
                    var validationResult = validator.GetValidationResult(contactInfo);

                    if (validationResult.HasErrors)
                    {
                        throw new ValidationException(validationResult);
                    }
                }

                uow.Repository.Add(contactInfo);
                uow.Commit();
            }
        }