public IActionResult Create(AddressViewModel address)
        {
            if (!ModelState.IsValid)
            {
                return(View(address));
            }
            _addressAppService.Add(address);

            ViewBag.SuccessCreated = GetMessageCreate(address);

            return(View(address));
        }
Exemple #2
0
        public IHttpActionResult AddAddress(AddressDTO addressDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var address = Mapper.Map <AddressDTO, Address>(addressDto);

            _addressAppService.Add(address);
            _uow.Save();

            addressDto.Id = address.Id;
            return(Created(new Uri(Request.RequestUri + "/" + address.Id), addressDto));
        }
Exemple #3
0
        public ActionResult Edit(ContactViewModel objContact)
        {
            try
            {
                #region Address
                var address = _addressApp.GetAddressByIdContact(objContact.Id);

                if (address == null && objContact.Address != null)
                {
                    var objAddress = new AddressViewModel()
                    {
                        Id            = objContact.Id,
                        StreetAddress = objContact.Address.StreetAddress,
                        City          = objContact.Address.City,
                        State         = objContact.Address.State,
                        PostalCode    = objContact.Address.PostalCode
                    };

                    var addressDomain = Mapper.Map <AddressViewModel, Address>(objAddress);
                    _addressApp.Add(addressDomain);
                }
                ;
                #endregion

                foreach (var item in objContact.Phone)
                {
                    item.ContactId = objContact.Id;
                }


                var contactDomain = Mapper.Map <ContactViewModel, Contact>(objContact);
                _contactApp.Update(contactDomain);

                return(Json(new { success = true, responseText = "Alterado com sucesso." }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, responseText = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
        public async Task <AjaxResponse <bool> > Add([FromBody] AddressCreateInput dto)
        {
            var res = await _appservice.Add(dto);

            return(new AjaxResponse <bool>(res));
        }