Пример #1
0
        public ActionResult Create([Bind(Include = "Id,Firstname,Lastname,Username,Password,Role_id")] Person person)
        {
            if (ModelState.IsValid)
            {
                db.Person.Add(person);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(person));
        }
Пример #2
0
        public IEnumerable <string> Get()
        {
            var dbContext = new ProgramDbContext();

            dbContext.SaveChanges();
            return(dbContext.Users.Select(u => u.Username));
        }
Пример #3
0
 public IActionResult Post(RegisterDataWrapper rdw)
 {
     if (rdw == null || string.IsNullOrEmpty(rdw.Password) ||
         string.IsNullOrEmpty(rdw.Email) || string.IsNullOrEmpty(rdw.Username))
     {
         return(BadRequest("Information for registration is invalid."));
     }
     if (!this.dbContext.Users.Where(u => u.Email == rdw.Email).Any())
     {
         dbContext.Add <User>(new User
         {
             Email    = rdw.Email,
             Password = rdw.Password,
             Username = rdw.Username,
         });
         dbContext.SaveChanges();
         return(Ok());
     }
     else
     {
         return(BadRequest("User already added."));
     }
 }