public void Save(Model model) { if (model.Id > 0) { dbSet.Update(model); context.SaveChanges(); return; } dbSet.Add(model); context.SaveChanges(); }
public string PostUsersClassModel(string userName, string password) { UsersClassModel usersClassModel = new UsersClassModel(); usersClassModel.UserName = userName; usersClassModel.Password = password; db.UsersClassModels.Add(usersClassModel); db.SaveChanges(); return("success"); }
public IHttpActionResult PostUser(User user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //encrypting the password. SHA1 s = SHA1.Create(); byte[] buffer = Encoding.ASCII.GetBytes(user.Password); byte[] hashCode = s.ComputeHash(buffer); user.Password = Convert.ToBase64String(hashCode); db.Users.Add(user); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { username = user.Username }, user)); }
public IActionResult AddCitizen(string name, string url) { var dbModel = new CitizenUser() { Login = name, AvatarUrl = url }; _webMazeContext.CitizenUser.Add(dbModel); _webMazeContext.SaveChanges(); return(RedirectToAction("Lvou", "Student")); }
public IActionResult AddCountry(string country, string capital, int population, double area, string flag) { var dbModel = new CountryDetails() { CountryName = country, Capital = capital, Population = population, Area = area, Flag = flag }; _webMazeContext.CountryDetails.Add(dbModel); _webMazeContext.SaveChanges(); return(RedirectToAction("Index", "Countries")); }
public void Save(Model user) { dbSet.Add(user); context.SaveChanges(); }