Пример #1
0
 public static LoaiYeuCauDTO FromEntity(LoaiYeuCau item)
 {
     return(new LoaiYeuCauDTO()
     {
         Id = item.Id,
         TenLoaiYeuCau = item.TenLoaiYeuCau,
         YeuCau = item.YeuCau?.Select(YeuCauDTO.FromEntity),
     });
 }
Пример #2
0
        public async Task <IActionResult> PostLoaiYeuCau([FromBody] LoaiYeuCau loaiyeucau)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var user   = User.Identity.Name;
            var userId = Utilities.GetUserId(this.User);

            loaiyeucau.NgayNhap  = DateTime.Now;
            loaiyeucau.NguoiNhap = user;
            _context.LoaiYeuCaus.Add(loaiyeucau);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLoaiYeuCau", new { id = loaiyeucau.LoaiYeuCauId }, loaiyeucau));
        }
Пример #3
0
        public async Task <IActionResult> PutLoaiYeuCau([FromRoute] int id, [FromBody] LoaiYeuCau loaiyeucau)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != loaiyeucau.LoaiYeuCauId)
            {
                return(BadRequest());
            }
            var user   = User.Identity.Name;
            var userId = Utilities.GetUserId(this.User);

            loaiyeucau.NgaySua  = DateTime.Now;
            loaiyeucau.NguoiSua = user;
            _context.Entry(loaiyeucau).State = EntityState.Modified;

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

            return(NoContent());
        }
Пример #4
0
 public async Task UpdateLoaiYeuCau(LoaiYeuCau loaiYeuCau)
 {
     await _loaiYeuCauRepository.UpdateAsync(loaiYeuCau);
 }
Пример #5
0
 public async Task CreateLoaiYeuCau(LoaiYeuCau loaiYeuCau)
 {
     await _loaiYeuCauRepository.AddAsync(loaiYeuCau);
 }