public ServerResponse Update(string personId, [FromBody] PersonEditModel model)
        {
            ServerResponse serverResponse = new ServerResponse();

            try
            {
                Person person = (from p in dbContext.People
                                 where p.PersonId == personId
                                 select p).First();

                person.Name = model.Name;
                person.Age  = model.Age;
                person.Sex  = model.Sex;

                dbContext.People.Update(person);
                dbContext.SaveChanges();
                serverResponse.Success = true;
                serverResponse.Message = "Person modified.";
            }
            catch (Exception)
            {
                serverResponse.Success = false;
                serverResponse.Message = "Person don't modified.";
            }

            return(serverResponse);
        }
示例#2
0
        public PersonViewModel Update(PersonEditModel model)
        {
            var entity         = this.ConvertToEntity(model);
            var executedEntity = this.appUnitOfWork.PersonRepository.Update(entity);

            return(this.ConvertToView(executedEntity));
        }
示例#3
0
        public ActionResult Edit(PersonEditModel model)
        {
            try
            {
                // var file = Request.Files[0];//get image

                var files = Request.Files;



                if (files.Count > 0)
                {
                    var file0        = files[0];
                    var relativePath = FilesHelper.RelativePath;
                    var path         = Server.MapPath(relativePath);
                    PersonOperations.CreateUpdate(model.details, files[0], path, true);
                }
                else
                {
                    PersonOperations.CreateUpdate(model.details, null, "", true);
                }
                return(RedirectToAction("Index", new { Type_ID = model.filter.Type_ID, SubType_ID = model.filter.SubType_ID, InMailingListOnly = model.filter.InMailingListOnly }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
        }
 public IActionResult Edit(PersonEditModel editPerson)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var UpdatedPerson = new Person();
             UpdatedPerson.Id                  = editPerson.Id;
             UpdatedPerson.FirstName           = editPerson.FirstName;
             UpdatedPerson.MiddleName          = editPerson.MiddleName;
             UpdatedPerson.LastName            = editPerson.LastName;
             UpdatedPerson.ExtensionName       = editPerson.ExtensionName;
             UpdatedPerson.NameTitleId         = editPerson.NameTitleId;
             UpdatedPerson.Sex                 = editPerson.Sex;
             UpdatedPerson.DateOfBirth         = editPerson.DateOfBirth;
             UpdatedPerson.CivilStatus         = editPerson.CivilStatus;
             UpdatedPerson.ContactNumber       = editPerson.ContactNumber;
             UpdatedPerson.DateTimeLastUpdated = DateTime.Now;
             _person.Update(UpdatedPerson);
             return(RedirectToAction("Index"));
         }
         return(View(editPerson));
     }
     catch (Exception err)
     {
         ModelState.AddModelError(err.ToString(), "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
     }
     return(View(editPerson));
 }
示例#5
0
        public ContentResult Save(PersonEditModel model, string login)
        {
            // create prerson
            var person = new Person();

            person.Name               = model.Name;
            person.DisplayName        = model.DisplayName;
            person.EnName             = model.EnName;
            person.Address            = model.Address;
            person.Email              = model.Email;
            person.IsNotResident      = model.IsNotResident;
            person.Comment            = model.Comment;
            person.Family             = (string.IsNullOrEmpty(model.Family)) ? "" : model.Family.ToUpperInvariant();
            person.GenitiveFamily     = model.GenitiveFamily;
            person.GenitiveName       = model.GenitiveName;
            person.GenitivePatronymic = model.GenitivePatronymic;
            person.Initials           = model.Initials;
            person.IsSubscribed       = model.IsSubscribed;
            person.Patronymic         = model.Patronymic;

            var personId = personLogic.CreatePerson(person);

            // phones
            foreach (var phone in model.Phones)
            {
                SavePhone(phone, personId);
            }

            // create user
            var user = new IdentityUser();

            user.Login    = login;
            user.Name     = model.Name;
            user.Email    = model.Email;
            user.PersonId = personId;
            var userId = identityLogic.CreateUser(user);

            // create employee for НОВЕЛКО

            var employee = new Employee();

            employee.PersonId = personId;
            employee.LegalId  = 1;
            employee.Comment  = model.Comment;

            employeeLogic.CreateEmployee(employee);

            //// create employee for НОВЕЛ логистик

            //employee = new Employee();
            //employee.PersonId = personId;
            //employee.LegalId = 2;
            //employee.Comment = model.Comment;

            //employeeLogic.CreateEmployee(employee);

            return(Content(JsonConvert.SerializeObject("")));
        }
示例#6
0
        public ActionResult Edit(Guid?id, PersonEditModel personEditModel, HttpPostedFileBase profilepic)
        {
            User user = null;

            // admin is trying to edit, authorize them
            if (id.HasValue)
            {
                // current user must be in User role
                if (Roles.IsUserInRole(RoleNames.User))
                {
                    user = _userRepository.GetNullableById(id.Value);
                }
            }
            else
            {
                user = Repository.OfType <User>().Queryable.Where(a => a.LoweredUserName == CurrentUser.Identity.Name.ToLower()).FirstOrDefault();
            }

            if (user == null)
            {
                return(this.RedirectToAction <ErrorController>(a => a.NotAuthorized()));
            }

            //var seminarPerson = _seminarPersonRepository.GetNullableById(personEditModel.SeminarPersonId);
            var person = SetPerson(personEditModel, null, ModelState, user.Person, profilepic);

            var membership = user.Membership;

            membership.SetEmail(personEditModel.Email);

            if (ModelState.IsValid)
            {
                _personRepository.EnsurePersistent(person);
                _membershipRepository.EnsurePersistent(membership);

                Message = string.Format(Messages.Saved, "Person");

                if (personEditModel.UserName != CurrentUser.Identity.Name.ToLower())
                {
                    user.SetUserName(personEditModel.UserName);
                    _userRepository.EnsurePersistent(user);

                    var formsService = new FormsAuthenticationService();
                    formsService.SignOut();
                    formsService.SignIn(user.LoweredUserName, false);
                }

                // send to crop photo if one was uploaded
                if (profilepic != null)
                {
                    return(this.RedirectToAction(a => a.UpdateProfilePicture(person.Id, null, true)));
                }
            }

            var viewModel = PersonViewModel.Create(Repository, _firmService, Site, null, person, user.Email);

            return(View(viewModel));
        }
示例#7
0
        public ActionResult AdminEdit(Guid id, int?seminarId, bool?allList, PersonEditModel personEditModel, HttpPostedFileBase profilepic)
        {
            var user = _userRepository.GetNullableById(id);

            if (user == null)
            {
                Message = string.Format(Messages.NotFound, "user", id);
                int sid = 0;

                if (!seminarId.HasValue)
                {
                    sid = SiteService.GetLatestSeminar(Site).Id;
                }
                else
                {
                    sid = seminarId.Value;
                }

                return(this.RedirectToAction <AttendeeController>(a => a.Index(sid)));
            }

            var seminarPerson = _seminarPersonRepository.GetNullableById(personEditModel.SeminarPersonId);
            var person        = SetPerson(personEditModel, seminarPerson, ModelState, user.Person, profilepic);

            var membership = user.Membership;

            user.SetUserName(personEditModel.UserName);
            membership.SetEmail(personEditModel.Email);

            if (ModelState.IsValid)
            {
                _personRepository.EnsurePersistent(person);
                _userRepository.EnsurePersistent(user);
                _membershipRepository.EnsurePersistent(membership);

                if (seminarPerson != null)
                {
                    _seminarPersonRepository.EnsurePersistent(seminarPerson);
                }
                Message = string.Format(Messages.Saved, "Person");

                // send to crop photo if one was uploaded
                if (profilepic != null)
                {
                    return(this.RedirectToAction(a => a.UpdateProfilePicture(person.Id, seminarId, true)));
                }

                return(this.RedirectToAction(a => a.AdminEdit(person.User.Id, seminarId, null)));
            }

            ViewBag.AllList = allList ?? false;
            var viewModel = AdminPersonViewModel.Create(Repository, _firmService, Site, seminarId, user.Person, user.Email);

            return(View(viewModel));
        }
示例#8
0
        public ActionResult CreatePerson(int id, PersonEditModel personEditModel, HttpPostedFileBase profilepic)
        {
            ModelState.Clear();

            var person = personEditModel.Person;

            var user = _userRepository.Queryable.FirstOrDefault(a => a.LoweredUserName == personEditModel.UserName.ToLower());

            person.User = user;

            SeminarPerson seminarPerson = null;

            person = SetPerson(personEditModel, seminarPerson, ModelState, person, profilepic);

            ModelState.Remove("Person.User");

            if (ModelState.IsValid)
            {
                // try to create the user
                var createStatus = _membershipService.CreateUser(personEditModel.UserName
                                                                 , Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 10)
                                                                 , personEditModel.Email);

                // retrieve the user to assign
                var createdUser = _userRepository.Queryable.FirstOrDefault(a => a.LoweredUserName == personEditModel.UserName.ToLower());
                person.User = createdUser;

                // save only if user creation was successful
                if (createStatus == MembershipCreateStatus.Success)
                {
                    person.AddSite(SiteService.LoadSite(Site));

                    // we're good save the person object
                    _personRepository.EnsurePersistent(person);
                    Message = string.Format(Messages.Saved, "Person");

                    if (person.OriginalPicture != null)
                    {
                        return(this.RedirectToAction <PersonController>(a => a.UpdateProfilePicture(person.Id, null, false)));
                    }

                    return(this.RedirectToAction <PersonController>(a => a.AdminEdit(person.User.Id, null, true)));
                }

                ModelState.AddModelError("Create User", AccountValidation.ErrorCodeToString(createStatus));
            }

            var viewModel = PersonViewModel.Create(Repository, _firmService, Site, null, person, personEditModel.Email);

            viewModel.Addresses = personEditModel.Addresses;
            viewModel.UserName  = personEditModel.UserName;
            return(View(viewModel));
        }
示例#9
0
        public ActionResult EditPerson(string subplatform, int id, PersonEditModel personEditModel)
        {
            byte[] image = null;
            if (ModelState.IsValid)
            {
                Person       person       = itemMgr.GetPerson(personEditModel.ItemId);
                Organisation organisation = null;
                if (personEditModel.OrganisationId != null && personEditModel.OrganisationId >= 1)
                {
                    organisation = itemMgr.GetOrganisation((int)personEditModel.OrganisationId);
                    if (organisation == null)
                    {
                        return(RedirectToAction("ItemBeheer", "Item"));
                    }
                }
                Subplatform Subplatform = SubplatformMgr.GetSubplatform(subplatform);
                var         iconUrl     = "";
                string      _FileName   = "";
                if (personEditModel.file != null)
                {
                    if (personEditModel.file.ContentLength > 0)
                    {
                        //_FileName = Path.GetFileName(personEditModel.file.FileName);
                        //var username = personEditModel.Name.ToString();
                        //var newName = username + "." + _FileName.Substring(_FileName.IndexOf(".") + 1);
                        //string _path = Path.Combine(Server.MapPath("~/Content/Images/Persons/"), newName);
                        //personEditModel.file.SaveAs(_path);
                        //iconUrl = @"~/Content/Images/Persons/" + newName;
                        //person.IconURL = iconUrl;
                        ImageConverter imgCon = new ImageConverter();
                        var            img    = Image.FromStream(personEditModel.file.InputStream);
                        image        = (byte[])imgCon.ConvertTo(img, typeof(byte[]));
                        person.Image = image;
                    }
                }
                else
                {
                    iconUrl = person.IconURL;
                }

                person.Gemeente        = personEditModel.Gemeente;
                person.IsTrending      = personEditModel.IsTrending;
                person.Organisation    = organisation;
                person.SocialMediaLink = personEditModel.SocialMediaLink;
                person.Name            = personEditModel.Name;
                person.District        = personEditModel.District;
                itemMgr.ChangePerson(person);
                return(RedirectToAction("ItemBeheer", "Item"));
            }
            return(RedirectToAction("ItemBeheer", "Item"));
        }
示例#10
0
 public JsonResult Edit(PersonEditModel model)
 {
     if (ModelState.IsValid)
     {
         var response = this.personService.Update(model);
         return(Json(response));
     }
     else
     {
         return(Json(ModelState.Values
                     .SelectMany(state => state.Errors)
                     .Select(error => error.ErrorMessage)));
     }
 }
示例#11
0
        protected PersonEntity ConvertToEntity(PersonEditModel model)
        {
            var result = new PersonEntity()
            {
                Id           = model.Id,
                FirstName    = model.FirstName,
                LastName     = model.LastName,
                Birthdate    = model.Birthdate,
                GenderId     = model.Gender,
                PersonNumber = model.PersonNumber,
                Salary       = model.Salary
            };

            return(result);
        }
示例#12
0
        public ActionResult Edit(long personId, PersonEditModel model)
        {
            try
            {
                manager.SaveEditModel(personId, model);

                var responseModel = manager.GetDetailsModel(personId);

                return(Ok(responseModel));
            }
            catch (KeyNotFoundException)
            {
                return(NotFound());
            }
        }
示例#13
0
        private Person SetPerson(PersonEditModel personEditModel, SeminarPerson seminarPerson, ModelStateDictionary modelState, Person person = null, HttpPostedFileBase profilePic = null)
        {
            modelState.Clear();

            person = person ?? personEditModel.Person;

            // copy all the fields
            Mapper.Map(personEditModel, person);

            SetAddresses(person, personEditModel.Addresses, ModelState);
            SetContacts(person, personEditModel.Contacts, ModelState);

            if (seminarPerson != null)
            {
                SetCommodities(seminarPerson, personEditModel.Commodities);

                if (personEditModel.Firm != null || !string.IsNullOrEmpty(personEditModel.FirmName))
                {
                    seminarPerson.Firm = personEditModel.Firm ?? new Firm(personEditModel.FirmName, personEditModel.FirmDescription)
                    {
                        WebAddress = personEditModel.FirmWebAddress
                    };
                }
                if (personEditModel.Title != null) //Not sure what is happening here. This may fix it.
                {
                    seminarPerson.Title = personEditModel.Title;
                }
            }

            // deal with the image))
            if (profilePic != null)
            {
                // blank out existing image files
                person.OriginalPicture    = null;
                person.MainProfilePicture = null;
                person.ThumbnailPicture   = null;

                // read the file and set the original picture
                var reader = new BinaryReader(profilePic.InputStream);
                person.OriginalPicture = reader.ReadBytes(profilePic.ContentLength);
                person.ContentType     = profilePic.ContentType;
            }

            // run the validation
            person.TransferValidationMessagesTo(modelState);

            return(person);
        }
        public IActionResult Edit(int Id)
        {
            Person person = _person.Get(Id);
            var    model  = new PersonEditModel()
            {
                Id            = person.Id,
                FirstName     = person.FirstName,
                MiddleName    = person.MiddleName,
                LastName      = person.LastName,
                ExtensionName = person.ExtensionName,
                NameTitle     = person.NameTitleId.ToString(),
                DateOfBirth   = person.DateOfBirth,
                Sex           = person.Sex,
                ContactNumber = person.ContactNumber,
            };

            return(View(model));
        }
示例#15
0
        public ActionResult PersonPartialCreate(string subplatform, PersonEditModel personEditModel)
        {
            byte[] image = null;
            if (ModelState.IsValid)
            {
                Subplatform  Subplatform  = SubplatformMgr.GetSubplatform(subplatform);
                Organisation organisation = null;
                if (personEditModel.OrganisationId != null && personEditModel.OrganisationId >= 1)
                {
                    organisation = itemMgr.GetOrganisation((int)personEditModel.OrganisationId);
                    if (organisation == null)
                    {
                        return(RedirectToAction("ItemBeheer", "Item"));
                    }
                }
                var    iconUrl   = "";
                string _FileName = "";
                if (personEditModel.file != null)
                {
                    if (personEditModel.file.ContentLength > 0)
                    {
                        //_FileName = Path.GetFileName(personEditModel.file.FileName);
                        //var username = personEditModel.Name.ToString();
                        //var newName = username + "." + _FileName.Substring(_FileName.IndexOf(".") + 1);
                        //string _path = Path.Combine(Server.MapPath("~/Content/Images/Persons/"), newName);
                        //personEditModel.file.SaveAs(_path);
                        //iconUrl = @"~/Content/Images/Persons/" + newName;
                        ImageConverter imgCon = new ImageConverter();
                        var            img    = Image.FromStream(personEditModel.file.InputStream);
                        image = (byte[])imgCon.ConvertTo(img, typeof(byte[]));
                    }
                }
                else
                {
                    iconUrl = Subplatform.Settings.Where(p => p.SettingName.Equals(Setting.Platform.DEFAULT_NEW_ITEM_ICON)).First().Value;
                }

                itemMgr.AddPerson(personEditModel.Name, personEditModel.SocialMediaLink, iconUrl, personEditModel.IsTrending, null, null, null, null, null, null, null, personEditModel.Gemeente, null, null, organisation, Subplatform, null, image);

                return(RedirectToAction("ItemBeheer", "Item"));
            }
            return(RedirectToAction("ItemBeheer", "Item"));
        }
示例#16
0
        public ActionResult EditPerson(int id)
        {
            Person          item   = itemMgr.GetPerson(id);
            PersonEditModel person = new PersonEditModel()
            {
                Name            = item.Name,
                IsTrending      = item.IsTrending,
                SocialMediaLink = item.SocialMediaLink,
                Gemeente        = item.Gemeente,
                ItemId          = item.ItemId,
                District        = item.District,
                Level           = item.Level,
                Site            = item.Site
            };

            if (item.Organisation != null)
            {
                person.OrganisationId = item.Organisation.ItemId;
            }
            return(View(person));
        }
示例#17
0
        public void SaveEditModel(long id, PersonEditModel model)
        {
            var item = dc.People.Find(X => X.Id == id);

            if (item == null)
            {
                throw new KeyNotFoundException();
            }
            else
            {
                item.CompanyId       = model.CompanyId;
                item.Forename        = model.Forename;
                item.Surname         = model.Surname;
                item.Email           = model.Email;
                item.JobTitle        = model.JobTitle;
                item.MobileNumber    = model.MobileNumber;
                item.TelephoneNumber = model.TelephoneNumber;

                //dc.Save();
            }
        }
示例#18
0
        public PersonEditModel GetPersonEditModel(Person person)
        {
            PersonDetailsModel details = new PersonDetailsModel
            {
                Person_Senior = person.Person_Senior,
                ID            = person.ID,
                TZ            = person.TZ,
                BirthDate     = person.BirthDate,
                FirstName     = person.FirstName,
                LastName      = person.LastName,
                DisplayName   = person.DisplayName,
                InMailingList = person.InMailingList,
                Degree        = person.Degree,

                Mobile           = person.Mobile,
                Phones           = person.Phones,
                Email            = person.Email,
                City             = person.City,
                ZipCode          = person.ZipCode,
                Address          = person.Address,
                Address_Comments = person.Address_Comments,
                Person_Comments  = person.Comments,

                Psyhology_LicenseNumber    = person.Psyhology_LicenseNumber,
                Psyhology_Specialization   = person.Psyhology_Specialization,
                Medicine_LicenseNumber     = person.Medicine_LicenseNumber,
                Medicine_Specialization    = person.Medicine_Specialization,
                Stomatology_LicenseNumber  = person.Stomatology_LicenseNumber,
                Stomatology_Specialization = person.Stomatology_Specialization,
                Ministry_CaseNumber        = person.Ministry_CaseNumber,
                ImageName = person.ImageName,
            };

            PersonEditModel editModel = new PersonEditModel();

            editModel.details = details;

            return(editModel);
        }
        public IActionResult Edit(PersonEditModel editPerson)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var model = Mapper.Map <PersonEditModel, Person>(editPerson);
                    _person.Update(model);
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception err)
            {
                ModelState.AddModelError(err.ToString(), "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
            }

            //PopulateWorksDropDownList(editPerson.WorkId);
            //PopulateNameTitleDropDownList(editPerson.NameTitleId);
            //PopulateReligionDropDownList(editPerson.ReligionId);

            return(View(editPerson));
        }
示例#20
0
        public async Task <HttpResponseMessage> Edit([FromBody] PersonEditModel model)
        {
            HttpResponseMessage returnMessage = new HttpResponseMessage();

            var personEditDto = mapper.Map <PersonEditDto>(model);
            var result        = await personSkillService.EditAsync(personEditDto);

            if (result.IsSuccess)
            {
                string message = ($"Person Update - {result.Entity.Id}");
                returnMessage = new HttpResponseMessage(HttpStatusCode.OK);
                returnMessage.RequestMessage = new HttpRequestMessage(HttpMethod.Put, message);
            }
            else
            {
                returnMessage = new HttpResponseMessage(HttpStatusCode.BadRequest);
                returnMessage.RequestMessage = new HttpRequestMessage(HttpMethod.Put, result.GetErrorString());
            }


            return(returnMessage);
        }
示例#21
0
        public ViewResult Fluent()
        {
            var model = new PersonEditModel
            {
                Person = new Person
                {
                    Gender = "M",
                    Name   = "Jeremy",
                    Roles  = new List <int> {
                        1, 2
                    },
                    Father = new Parent {
                        Name = "Jim"
                    },
                    Mother = new Parent {
                        Name = "Joan"
                    }
                },
                Genders = new Dictionary <string, string> {
                    { "M", "Male" }, { "F", "Female" }
                },
                Roles = new List <Role> {
                    new Role(0, "Administrator"), new Role(1, "Developer"), new Role(2, "User")
                },
                Companies = new SelectList(new List <Company>
                {
                    new Company {
                        Id = Guid.NewGuid(), Name = "Acme Inc"
                    },
                    new Company {
                        Id = Guid.NewGuid(), Name = "MicorSoft"
                    }
                }, "Id", "Name"),
                Shifts = new[] { "Day", "Night", "Graveyard" }
            };

            return(View(model));
        }
        public IActionResult Edit(Guid personGuid)
        {
            if (personGuid == Guid.Empty)
            {
                return(BadRequest(ModelState));
            }

            var person =
                _personData.ReadPerson(personGuid);

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

            var editModel = new PersonEditModel();

            editModel.GenderType = (PersonGenderTypeOptions)person.Gender;

            // Page navigation
            ViewData["PersonGuid"] = person.PersonGuid;

            return(View(editModel));
        }
示例#23
0
        public ActionResult Edit(int Id, int?type_ID, int?subType_ID, bool inMailingListOnly)
        {
            Person card = PersonOperations.GetPersonById(Id);

            if (card == null)
            {
                return(RedirectToAction("Index", new { Type_ID = type_ID, SubType_ID = subType_ID, InMailingListOnly = inMailingListOnly }));
            }
            PersonEditModel model = PersonOperations.GetPersonEditModel(card);

            model.filter = new EventsFilterViewModel_ForList
            {
                Type_ID           = type_ID,
                SubType_ID        = subType_ID,
                InMailingListOnly = inMailingListOnly
            };
            model.eventsFilter = new EventsFilterViewModel_ForCard()
            {
                Category_ID = 2,
                Card_ID     = Id
            };

            return(View(model));
        }
        public MessageModel AddPerson(PersonEditModel input)
        {
            try
            {
                Person result = new Person();
                ObjectMapper.Map(input, result);
                this._personRepository.Insert(result);

                return(new MessageModel()
                {
                    isSuccess = true,
                    title = "新增成功"
                });
            }
            catch (Exception ex)
            {
                return(new MessageModel()
                {
                    isSuccess = false,
                    title = "新增失敗",
                    message = ex.Message
                });
            }
        }
示例#25
0
 public UpdatePersonCommand(PersonEditModel model, IMediator mediator)
 {
     Model     = model;
     _mediator = mediator;
 }
示例#26
0
        public JsonResult Delete(PersonEditModel model)
        {
            var response = this.personService.Delete(model);

            return(Json(response));
        }
 public JsonResult SavePerson(PersonEditModel model)
 {
     return(Json("", JsonRequestBehavior.AllowGet));
 }
示例#28
0
 private void EditHouseholdHeadProc()
 {
     IsEditingHouseholdHead = true;
     HouseholdEditModel     = new PersonEditModel(SelectedHousehold.HouseholdHead.Model);
 }
示例#29
0
 private void CheckMapping(Person p, PersonEditModel pe)
 {
     pe.ShouldNotBe(null);
     pe.Id.ShouldBe(p.Id);
 }
        public IActionResult Edit(Guid personGuid, PersonEditModel editModel)
        {
            if (personGuid == Guid.Empty)
            {
                return(BadRequest(ModelState));
            }

            var person =
                _personData.GetPerson(personGuid);

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

            // Page navigation
            ViewData["PersonGuid"] = person.PersonGuid;

            //
            // Validate
            //

            if (!ModelState.IsValid)
            {
                return(View(editModel));
            }

            //
            // Edit
            //

            person.Gender = (PersonGender)editModel.GenderType;

            try
            {
                _personData.UpdatePerson(person);
            }
            catch (DbUpdateException /* ex */)
            {
                // Log the error (uncomment ex variable name and write a log.)
                ModelState.AddModelError(
                    "",
                    "Unable to save changes. " +
                    "Try again, and if the problem persists, " +
                    "see your system administrator.");

                return(View(editModel));
            }

            //
            // Update RDF
            //

            var readPerson = _personData.ReadAllPersonData(personGuid);

            if (readPerson != null)
            {
                _rdfData.AddOrUpdatePerson(readPerson);
            }

            //
            // Update search index
            //

            // TODO try catch to handle errors
            _personSearchIndex.MergeGender(
                person.PersonGuid.ToString(),
                person.Gender.ToString());

            //
            // Redirect
            //

            return(RedirectToAction(
                       "Details",
                       "Person",
                       new { personGuid = person.PersonGuid }));
        }