Exemplo n.º 1
0
 public async Task <IActionResult> Post([FromBody] LoaiKhoanChiDTO model)
 {
     using (var context = new UserProfileDbContext())
     {
         context.LoaiKhoanChis.Add(new LoaiKhoanChi
         {
             Id = model.Id,
             TenLoaiKhoanChi = model.TenLoaiKhoanChi,
             ThuTu           = model.ThuTu,
             SuDung          = model.SuDung
         });
         //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[UserProfiles] ON");
         return(Ok(await context.SaveChangesAsync()));
     }
 }
Exemplo n.º 2
0
        public async Task <IActionResult> Put(int id, [FromBody] LoaiKhoanChiDTO model)
        {
            using (var context = new UserProfileDbContext())
            {
                var user = await context.LoaiKhoanChis.FirstOrDefaultAsync(x => x.Id.Equals(id));

                if (user == null)
                {
                    return(NotFound());
                }
                user.Id = model.Id;
                user.TenLoaiKhoanChi = model.TenLoaiKhoanChi;
                user.ThuTu           = model.ThuTu;
                user.SuDung          = model.SuDung;
                return(Ok(await context.SaveChangesAsync()));
            }
        }