示例#1
0
        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");
        }
示例#3
0
        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));
        }
示例#4
0
        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"));
        }
示例#5
0
        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"));
        }
示例#6
0
 public void Save(Model user)
 {
     dbSet.Add(user);
     context.SaveChanges();
 }