public bool EditUser(User editUser) { var user = _context.Users.Where(p => p.Nickname == editUser.Nickname).FirstOrDefault(); if (user != null) { _context.Configuration.ValidateOnSaveEnabled = false; // turns off validation user = editUser; _context.SaveChanges(); return(true); } return(false); }
public bool SaveContols(List <WordControl> controls) { string userNick = System.Web.HttpContext.Current.User.Identity.Name; var user = _context.Users.Where(x => x.Nickname == userNick).First(); for (int i = 0; i < controls.Count; i++) { if (controls[i].Text != null || controls[i].Type == 8) { var title = controls[i].Title; var isExist = user.DBcontrols.Where(x => x.Title == title).FirstOrDefault(); if (isExist != null) //Update { isExist.Title = controls[i].Title; isExist.Text = controls[i].Text; isExist.Control_ID = controls[i].Control_ID; isExist.Users.Id = user.Id; isExist.Checked = controls[i].Checked; } else { DBcontrol dbc = new DBcontrol() //Create { Title = controls[i].Title, Text = controls[i].Text, Control_ID = controls[i].Control_ID, Checked = controls[i].Checked, Users = user }; _context.DBcontrols.Add(dbc); } _context.SaveChanges(); } } return(true); }
public bool AddFormat(Format add) { _context.Formats.Add(add); _context.SaveChanges(); return(true); }