public ContactPersonDto(ContactPersons contactPerson) { Id = contactPerson.CtpId; ClientId = contactPerson.CtpCltId; ContragentId = contactPerson.CtpCgtId; Email = contactPerson.CtpEmail; Messanger = contactPerson.CtpMessanger; MessangerType = contactPerson.CtpMessangerType; Name = contactPerson.CtpName; PhoneNumber = contactPerson.CtpPhoneNumber; Position = contactPerson.CtpPosition; Skype = contactPerson.CtpSkype; Surname = contactPerson.CtpSurname; }
public string ContactsToString() { string result = ""; ContactPersons.OrderBy(val => val.TypeID).ThenBy(val => val.ID).ToList().ForEach(val => { var text = val.ContactsToString(); //if (text.IsNotNullOrEmpty()) { result += val.FullName + ": " + text + " \n"; } }); return(result); }
public ContactPersonDto SaveContactPerson([FromBody] ContactPersonDto contactPerson) { using (DB_A12601_bielkaContext context = new DB_A12601_bielkaContext()) { ContactPersons ctp; if (contactPerson.Id != 0) { ctp = context.ContactPersons.FirstOrDefault(c => c.CtpId == contactPerson.Id); } else { ctp = new ContactPersons { CtpAuditCd = DateTime.UtcNow, CtpAuditCu = User.GetUserId() }; context.ContactPersons.Add(ctp); } if (ctp == null) { return(null); } ctp.CtpCgtId = contactPerson.ContragentId; ctp.CtpCltId = contactPerson.ClientId; ctp.CtpEmail = contactPerson.Email; ctp.CtpMessanger = contactPerson.Messanger; ctp.CtpName = contactPerson.Name; ctp.CtpPhoneNumber = contactPerson.PhoneNumber; ctp.CtpPosition = contactPerson.Position; ctp.CtpSurname = contactPerson.Surname; ctp.CtpSkype = contactPerson.Skype; ctp.CtpAuditMd = DateTime.UtcNow; ctp.CtpAuditMu = User.GetUserId(); ctp.CtpMessangerType = contactPerson.MessangerType; context.SaveChanges(); contactPerson.Id = ctp.CtpId; return(contactPerson); } }
public bool DeleteContactPerson([FromBody] int contactPersonId) { using (DB_A12601_bielkaContext context = new DB_A12601_bielkaContext()) { ContactPersons ctp = context.ContactPersons.FirstOrDefault(c => c.CtpId == contactPersonId); if (ctp == null) { return(false); } ctp.CtpAuditRd = DateTime.UtcNow; ctp.CtpAuditRu = User.GetUserId(); context.SaveChanges(); return(true); } }