Ejemplo n.º 1
0
        public PartialViewResult EditContact(int id)
        {
            Contacts      eFContact = contactService.GetById(id);
            EditContactVm model     = new EditContactVm();

            model.Id             = id;
            model.Title          = eFContact.Title;
            model.FirstName      = eFContact.FirstName;
            model.LastName       = eFContact.LastName;
            model.OrganisationId = eFContact.FkOrganisationId;
            model.JobTitle       = eFContact.JobTitle;
            model.Phone          = eFContact.Phone;
            model.Mobile         = eFContact.Mobile;
            model.Email          = eFContact.Email;
            model.Address1       = eFContact.Address1;
            model.Address2       = eFContact.Address2;
            model.Address3       = eFContact.Address3;
            model.City           = eFContact.City;
            model.County         = eFContact.County;
            model.Postcode       = eFContact.Postcode;
            model.Country        = eFContact.Country;
            model.Description    = eFContact.Description;

            return(PartialView("_ModalEditContact", model));
        }
Ejemplo n.º 2
0
        public JsonResult EditContact(EditContactVm model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //convert model to ef model
                    Contacts eFContact = contactService.GetById(model.Id);
                    eFContact.Id               = model.Id;
                    eFContact.Title            = model.Title;
                    eFContact.FirstName        = model.FirstName;
                    eFContact.LastName         = model.LastName;
                    eFContact.FkOrganisationId = model.OrganisationId;
                    eFContact.JobTitle         = model.JobTitle;
                    eFContact.Phone            = model.Phone;
                    eFContact.Mobile           = model.Mobile;
                    eFContact.Email            = model.Email;
                    eFContact.Address1         = model.Address1;
                    eFContact.Address2         = model.Address2;
                    eFContact.Address3         = model.Address3;
                    eFContact.City             = model.City;
                    eFContact.County           = model.County;
                    eFContact.Postcode         = model.Postcode;
                    eFContact.Country          = model.Country;
                    eFContact.FkRefStatusId    = (int)StatusEnum.Active;
                    eFContact.Description      = model.Description;

                    contactService.Update(eFContact);
                    return(Json(new { status = CommonConstants.Ok, message = CommonConstants.Ok }));
                }
                catch (Exception e)
                {
                    return(Json(new { status = CommonConstants.Error, message = CommonConstants.SomethingWentWrong }));
                }
            }
            else
            {
                return(Json(new { status = CommonConstants.Error, message = CommonConstants.FailedValidation }));
            }
        }