public bool AddUser(AppUser User) { using (DBModel1 cm = new DBModel1()) { address adr = new address() { Address1 = User.Address, Inn = User.Inn }; cm.Address.Add(adr); cm.SaveChanges(); people p = new people() { Birthdate = User.Birthdate, Firstname = User.Firstname, Inn = User.Inn, Passport_num = User.Passport_num, Passport_ser = User.Passport_ser, Patronymic = User.Patronymic, Surname = User.Surname }; cm.People.Add(p); cm.SaveChanges(); return(true); } }
public void UploadDocument(string Inn, File file) { using (DBModel1 cm = new DBModel1()) { var doc = cm.Documents.FirstOrDefault(f => f.Inn == Inn); if (doc != null) { cm.Documents.Remove(doc); cm.SaveChanges(); } doc = new documents(); doc.FileName = file.Name; doc.Data = file.Content; doc.Inn = Inn; cm.Documents.Add(doc); cm.SaveChanges(); } }