public ActionResult Create(Guid contactId)
        {
            var contactInfoDetailDto = new ContactInfoDetailDto
            {
                ContactId = contactId
            };

            return(View(contactInfoDetailDto));
        }
 public void UpdateContactInfo(ContactInfoDetailDto contactInfoDetailDto)
 {
     using (var uow = unitOfWorkFactory.GetUnitOfWork())
     {
         var contactInfo = Mapper.Map <ContactInfo>(contactInfoDetailDto);
         //ValidateAndThrow(contactInfo);
         uow.Repository.Update(contactInfo);
         uow.Commit();
     }
 }
Exemple #3
0
        public void CreateContactInfo(ContactInfoDetailDto contactInfoDetailDto)
        {
            using (var uow = GetUnitOfWork())
            {
                var contactInfo = Map <ContactInfo, ContactInfoDetailDto>(contactInfoDetailDto);
                ValidateAndThrow(contactInfo);

                uow.Repository.Add(contactInfo);
                uow.Commit();
            }
        }
Exemple #4
0
        public async Task UpdateContactInfoAsync(ContactInfoDetailDto contactInfoDetailDto)
        {
            using (var uow = unitOfWorkFactory.GetUnitOfWork())
            {
                var contactInfo = Mapper.Map <ContactInfo>(contactInfoDetailDto);
                //ValidateAndThrow(contactInfo);
                await uow.Repository.UpdateAsync(contactInfo);

                await uow.CommitAsync();
            }
        }
 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));
     }
 }
Exemple #6
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));
     }
 }
        public async Task <HttpResponseMessage> Create(ContactInfoDetailDto contact)
        {
            try
            {
                await this.contactApplicationService.CreateContactInfoAsync(contact);

                return(Request.CreateResponse(HttpStatusCode.Created, contact));
            }
            catch (ValidationException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
 public ActionResult Edit(ContactInfoDetailDto contactInfoDetailDto)
 {
     if (ModelState.IsValid)
     {
         try
         {
             this.contactApplicationService.UpdateContactInfoAsync(contactInfoDetailDto);
             return(RedirectToAction("Edit", "Contacts", new { id = contactInfoDetailDto.ContactId }));
         }
         catch (ValidationException ex)
         {
             ModelState.AddValidationErrors(ex);
         }
     }
     return(View(contactInfoDetailDto));
 }
Exemple #9
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));
        }
        public void UpdateContactInfo(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.Update(contactInfo);
                uow.Commit();
            }
        }