internal void SaveChild(ChildDTO c) { using (BackendContext context = new BackendContext()) { User user = new User() { UserName = c.UserName, Password = c.Password, }; context.Users.Add(user); context.SaveChanges(); var id = context.Users.Where(e => e.UserName == c.UserName).First().Id; Child child = new Child() { Id = id, Surname = c.Surname, Name = c.Name, }; context.Children.Add(child); context.SaveChanges(); } }
internal bool modifyChild(ChildDTO child) { try { using (BackendContext context = new BackendContext()) { context.Users.Single(u => u.Id == child.Id).Password = child.Password; context.SaveChanges(); } } catch (Exception ex) { Console.WriteLine(ex.Message); return(false); } return(true); }