public async Task <IHttpActionResult> GetDetails(string id) { string _ParentUnitCode = _service.GetParentUnitCode(); TransferObj <NvNgayHetHanHangHoaVm.Dto> result = new TransferObj <NvNgayHetHanHangHoaVm.Dto>(); NvNgayHetHanHangHoaVm.Dto temp = new NvNgayHetHanHangHoaVm.Dto(); NvNgayHetHanHangHoa phieu = _service.FindById(id); if (phieu != null) { temp = Mapper.Map <NvNgayHetHanHangHoa, NvNgayHetHanHangHoaVm.Dto>(phieu); List <NvNgayHetHanHangHoaChiTiet> chiTietPhieu = _service.UnitOfWork.Repository <NvNgayHetHanHangHoaChiTiet>().DbSet.Where(x => x.MaPhieuPk == phieu.MaPhieuPk).ToList(); temp.DataDetails = Mapper.Map <List <NvNgayHetHanHangHoaChiTiet>, List <NvNgayHetHanHangHoaVm.DtoDetail> >(chiTietPhieu); } result.Data = temp; result.Status = true; return(Ok(result)); }
public async Task <IHttpActionResult> Post(NvNgayHetHanHangHoaVm.Dto instance) { TransferObj <NvNgayHetHanHangHoa> result = new TransferObj <NvNgayHetHanHangHoa>(); try { NvNgayHetHanHangHoa item = _service.InsertPhieu(instance); await _service.UnitOfWork.SaveAsync(); result.Data = item; result.Status = true; return(CreatedAtRoute("DefaultApi", new { controller = this, id = instance.Id }, result)); } catch (Exception e) { return(InternalServerError()); } }
public async Task <IHttpActionResult> Put(string id, NvNgayHetHanHangHoaVm.Dto instance) { TransferObj <NvNgayHetHanHangHoa> result = new TransferObj <NvNgayHetHanHangHoa>(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } NvNgayHetHanHangHoa check = _service.FindById(instance.Id); try { NvNgayHetHanHangHoa item = _service.UpdatePhieu(instance); await _service.UnitOfWork.SaveAsync(); result.Status = true; result.Data = item; return(Ok(result)); } catch (Exception e) { return(InternalServerError()); } }