public ActionResult GetPerson(int PersonId) { var PersonFromModel = _Person.GetPerson(PersonId); var ToReturn = new _Person(PersonFromModel); return(Json(ToReturn, JsonRequestBehavior.AllowGet)); }
public ActionResult UpdatePerson(int PersonId, string PersonName, int CityId) { var UpdatedPersonFromModel = _Person.UpdatePerson(PersonId, PersonName, CityId); var ToReturn = new _Person(UpdatedPersonFromModel); return(Json(ToReturn, JsonRequestBehavior.AllowGet)); }
public ActionResult CreatePerson(string PersonName, int CityId) { var PersonFromModel = _Person.CreatePerson(PersonName, CityId); var ToReturn = new _Person(PersonFromModel); return(Json(ToReturn, JsonRequestBehavior.AllowGet)); }
public static async Task <_Person> DbToPersonAsync(Person person, ApplicationDbContext context) { _Person convertedPerson = new _Person(); #region Same property Content Cloning #region Unneeded //convertedPerson.Id = person.Id; //convertedPerson.Name = person.Name; //convertedPerson.Surname = person.Surname; //convertedPerson.Role = person.Role; //convertedPerson.GithubLink = person.GithubLink; //convertedPerson.LinkedInLink = person.LinkedInLink; //foreach (var property in typeof(Person).GetProperties()) //{ // if (property.Name.ToString() == "ProjectIds") continue; // var editedProp = property.GetValue(person); // property.SetValue(convertedPerson, editedProp); //} #endregion convertedPerson = Helper.Copy.Action(person, convertedPerson); #endregion #region Ids to Project Arrays List <int> ids = new List <int>(); try { foreach (var id in person.ProjectIds.Split('-')) { try { ids.Add(int.Parse(id)); } catch (Exception) { } } } catch (ArgumentNullException) { } List <Project> projects = new List <Project>(); foreach (var id in ids) { projects.Add(await context.Project.FindAsync(id)); } convertedPerson.Projects = projects.ToArray(); #endregion return(convertedPerson); }
//[Test] public void Test_EditableList_AcceptChanges() { _Person person = TypeAccessor <_Person> .CreateInstance(); person.Phones.AddRange(new _PersonPhone[] { TypeAccessor <_PersonPhone> .CreateInstanceEx(), TypeAccessor <_PersonPhone> .CreateInstanceEx() }); person.Phones[1].Number_PersonPhone = "222-22-22"; person.AcceptChanges(); Assert.IsFalse(person.IsDirty); Assert.IsTrue(IsAcceptChangesCallForPersonPhone); }