public static LoaiYeuCauDTO FromEntity(LoaiYeuCau item) { return(new LoaiYeuCauDTO() { Id = item.Id, TenLoaiYeuCau = item.TenLoaiYeuCau, YeuCau = item.YeuCau?.Select(YeuCauDTO.FromEntity), }); }
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)); }
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()); }
public async Task UpdateLoaiYeuCau(LoaiYeuCau loaiYeuCau) { await _loaiYeuCauRepository.UpdateAsync(loaiYeuCau); }
public async Task CreateLoaiYeuCau(LoaiYeuCau loaiYeuCau) { await _loaiYeuCauRepository.AddAsync(loaiYeuCau); }