public IHttpActionResult CreateGroupProduct(NhomHangHoa nhomhanghoa) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _db.NhomHangHoa.Add(nhomhanghoa); _db.SaveChanges(); return(Created(new Uri(Request.RequestUri + "/" + nhomhanghoa.Id), nhomhanghoa)); }
public IHttpActionResult Create(HangHoaDTO hanghoaDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var hanghoa = Mapper.Map <HangHoaDTO, HangHoa>(hanghoaDTO); _db.HangHoa.Add(hanghoa); _db.SaveChanges(); hanghoaDTO.Id = hanghoa.Id; return(Created(new Uri(Request.RequestUri + "/" + hanghoaDTO.Id), hanghoaDTO)); }