public async Task <ActionResult <UserModel> > PostUser([FromBody] UserModel user)
        {
            User user1 = new User();

            user1.IdUser      = user.IdUser;
            user1.UserAccount = user.UserAccount;;
            user1.Password    = user.Password;
            user1.UserName    = user.UserName;
            user1.PhoneNumber = user.PhoneNumber;
            user1.Bday        = user.Bday;
            user1.Email       = user.Email;
            user1.Address     = user.Address;
            _context.User.Add(user1);
            await _context.SaveChangesAsync();

            //var u = _context.User;
            //var up = _context.UserPer;
            //var p = _context.Permission;
            UserPer up = new UserPer();

            up.IdUser   = user1.IdUser;
            up.IdPer    = user.IdPer;
            up.Licensed = 1;
            _context.UserPer.Add(up);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetUser", new { id = user.IdUser }, user));
        }
Beispiel #2
0
        public async Task <IActionResult> PutNhomKd(string id, NhomKd nhomKd)
        {
            if (id != nhomKd.MaNhomKd)
            {
                return(BadRequest());
            }

            _context.Entry(nhomKd).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NhomKdExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutPerDetail1(int id, PerDetail1 perDetail1)
        {
            if (id != perDetail1.IdDetail)
            {
                return(BadRequest());
            }

            _context.Entry(perDetail1).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PerDetail1Exists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutDongTb(string id, DongTb dongTb)
        {
            if (id != dongTb.IddongTb)
            {
                return(BadRequest());
            }

            _context.Entry(dongTb).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DongTbExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #5
0
        public async Task <IActionResult> PutUser(int id, User user)
        {
            if (id != user.IdUser)
            {
                return(BadRequest());
            }

            _context.Entry(user).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }