private void FixupPerson(Person previousValue)
        {
            if (previousValue != null && previousValue.FixedAssets.Contains(this))
            {
                previousValue.FixedAssets.Remove(this);
            }

            if (Person != null)
            {
                if (!Person.FixedAssets.Contains(this))
                {
                    Person.FixedAssets.Add(this);
                }
                if (id_person != Person.id)
                {
                    id_person = Person.id;
                }
            }
            else if (!_settingFK)
            {
                id_person = null;
            }
        }
 private void UpdatePerson(ref Person person, PersonSectionAddEditModel personSection)
 {
     if (personSection.id != 0) person.id = personSection.id; else person.id = 0;
     if (personSection.area_code != null) person.area_code = personSection.area_code; else person.area_code = null;
     if (personSection.email != null) person.email = personSection.email; else person.email = null;
     if (personSection.name != null) person.name = personSection.name.ToUpper(); else person.name = null;
     if (personSection.phone_number != null) person.phone_number = personSection.phone_number; else person.phone_number = null;
     if (personSection.phone_number2 != null) person.phone_number2 = personSection.phone_number2; else person.phone_number2 = null;
     if (personSection.surname != null) person.surname = personSection.surname.ToUpper(); else person.surname = null;
        // person.id_section = GetAllShortNameSections().Where(x => x.Value == personSection.section_name).Select(x => x.Key).First();
     int id = 0;
     int.TryParse(personSection.section_name, out id);
     person.id_section = id;
 }
        private Person CreatePersonFromPersonSectionAddEditModel(PersonSectionAddEditModel model)
        {
            Person person = new Person();
            person.area_code = model.area_code;
            person.email = model.email;
            person.id = model.id;
            int id_section;
            int.TryParse(model.section_name, out id_section);
            person.id_section = id_section;
            person.name = model.name;
            person.phone_number = model.phone_number;
            person.phone_number2 = model.phone_number2;
            person.surname = model.surname;

            return person;
        }
 private PersonSectionAddEditModel CreatePersonSetionAddEditFromPerson(Person person)
 {
     PersonSectionAddEditModel temp = new PersonSectionAddEditModel();
     temp.area_code = person.area_code;
     temp.email = person.email;
     temp.id = person.id;
     temp.name = person.name;
     temp.phone_number = person.phone_number;
     temp.phone_number2 = person.phone_number2;
     temp.surname = person.surname;
     // delete because @Html.DropDownListFor(x => x.section_name, @Model.SectionList) doesn't work properly
     //temp.section_name = section_ctrl.GetAllShortNameSections().Where(x => x.Key == person.id_section).Select(x => x.Value).First();
     temp.SectionList = section_ctrl.SectionsShortNamesList();
     var p = temp.SectionList.FirstOrDefault(x => x.Value == person.id_section.ToString());
     p.Selected = true;
     return temp;
 }
 public ActionResult Delete(DeleteObjectById model)
 {
     try
     {
         Person person = new Person() { id = model.Id };
         personRepository.DeleteObject(person);
         return RedirectToAction("Index");
     }
     catch (Exception ex)
     {
         throw new Exception("Wystąpił błąd podczas usuwania pracownika. Proszę skontaktować się z administratorem", ex.InnerException);
     }
 }