Exemplo n.º 1
0
        public async Task <ActionResult> UpdateContactDetail(string ContactId, string FirstName, string LastName, string Title, string Webaddress, string Address1,
                                                             string Address2, string Suburb, string State, string PostalCode, string Workphone, string Mobile, string Fax, string Homephone, string Email)
        {
            ClaimTeamLoginModel client = (ClaimTeamLoginModel)Session[SessionHelper.claimTeamLogin];
            ContactUpdateModel  model  = new ContactUpdateModel();

            model.ContactId  = ContactId;
            model.FirstName  = FirstName;
            model.LastName   = LastName;
            model.Title      = Title;
            model.Webaddress = Webaddress;
            model.Address1   = Address1;
            model.Address2   = Address2;
            model.Suburb     = Suburb;
            model.State      = State;
            model.PostalCode = PostalCode;
            model.Workphone  = Workphone;
            model.Mobile     = Mobile;
            model.Fax        = Fax;
            model.Homephone  = Homephone;
            model.Email      = Email;
            ContactRepo contactRepo = new ContactRepo();
            bool        result      = await contactRepo.UpdateContact(model, client.UserId);

            return(RedirectToAction("Index"));
        }
        public ActionResult UpdateContact(ContactModel ContactModelObj)
        {
            ContactRepo ContactRepoObj = new ContactRepo();

            try
            {
                if (ModelState.IsValid)
                {
                    if (ContactRepoObj.UpdateContact(ContactModelObj))
                    {
                        ViewBag.Message = "Contact details updated successfully";
                    }
                }
                return(RedirectToAction("GetAllContactDetails"));
            }
            catch
            {
                return(RedirectToAction("GetAllContactDetails"));
            }
        }
Exemplo n.º 3
0
        public ActionResult EditContact([FromQuery] string Dni, [FromBody] JsonPatchDocument <ContactUpdateDTO> patchDoc)
        {
            // Check if exists
            var contactFromRepo = _repository.ExistContactedPerson(Dni);

            if (contactFromRepo == null)
            {
                return(NotFound());
            }

            var contactToPatch = _mapper.Map <ContactUpdateDTO>(contactFromRepo);

            patchDoc.ApplyTo(contactToPatch);

            _mapper.Map(contactToPatch, contactFromRepo);

            _repository.UpdateContact(contactFromRepo);
            _repository.SaveChanges();

            return(NoContent());
        }