public ActionResult ReceivedOrder(int id) { DeliveryOrderResponse _response = new DeliveryOrderResponse(); var request = new DeliveryOrderRequest { Data = new DeliveryOrderModel { Id = id } }; DeliveryOrderResponse resp = new DeliveryOrderHandler(_unitOfWork).GetDetail(request); resp.Entity.Account = (AccountModel)Session["UserLogon"]; resp.Entity.Recived = 1; resp.Entity.approve = 1; var receiveddeliveryorder = new DeliveryOrderRequest { Data = resp.Entity, Action = ClinicEnums.Action.APPROVE.ToString() }; new DeliveryOrderValidator(_unitOfWork).Validate(receiveddeliveryorder, out _response); DeliveryOrderModel _model = resp.Entity; foreach (var item in resp.Entity.deliveryOrderDetailModels) { var requestproductingudang = new ProductInGudangRequest { Data = new ProductInGudangModel { Account = (AccountModel)Session["UserLogon"], stock = Convert.ToInt32(item.qty_request) > 0 ? Convert.ToInt32(item.qty_request) : Convert.ToInt32(item.qty_request), GudangId = _model.GudangId, ProductId = item.ProductId } }; var requesthistoryproductingudang = new HistoryProductInGudangRequest { Data = new HistoryProductInGudangModel { Account = (AccountModel)Session["UserLogon"], value = Convert.ToInt32(item.qty_request) > 0 ? Convert.ToInt32(item.qty_request) : Convert.ToInt32(item.qty_request), GudangId = Convert.ToInt32(_model.GudangId), ProductId = item.ProductId } }; var saveproductingudang = new ProductInGudangHandler(_unitOfWork).CreateOrEdit(requestproductingudang); var savehistoryproductingudang = new HistoryProductInGudangHandler(_unitOfWork).CreateOrEdit(requesthistoryproductingudang); } return(RedirectToAction("DeliveryOrderList")); }
public JsonResult ReceivedDeliveryOrder(int id) { DeliveryOrderPusatResponse _response = new DeliveryOrderPusatResponse(); var request = new DeliveryOrderPusatRequest { Data = new DeliveryOrderPusatModel { Id = id } }; DeliveryOrderPusatResponse resp = new DeliveryOrderPusatHandler(_unitOfWork).GetDetail(request); resp.Entity.Account = (AccountModel)Session["UserLogon"]; resp.Entity.Recived = 1; resp.Entity.Validasi = 1; var receiveddeliveryorder = new DeliveryOrderPusatRequest { Data = resp.Entity }; new DeliveryOrderPusatHandler(_unitOfWork).ApproveData(receiveddeliveryorder); new DeliveryOrderPusatValidator(_unitOfWork).Validate(receiveddeliveryorder, out _response); DeliveryOrderPusatModel _model = resp.Entity; foreach (var item in resp.Entity.deliveryOrderDetailpusatModels) { var requestproductingudang = new ProductInGudangRequest { Data = new ProductInGudangModel { Account = (AccountModel)Session["UserLogon"], stock = Convert.ToInt32(item.qty_final) > 0 ? Convert.ToInt32(item.qty_final) : Convert.ToInt32(item.qty_final), GudangId = _model.GudangId, ProductId = item.ProductId } }; var requesthistoryproductingudang = new HistoryProductInGudangRequest { Data = new HistoryProductInGudangModel { Account = (AccountModel)Session["UserLogon"], value = Convert.ToInt32(item.qty_final) > 0 ? Convert.ToInt32(item.qty_final) : Convert.ToInt32(item.qty_final), GudangId = Convert.ToInt32(_model.GudangId), ProductId = item.ProductId } }; var saveproductingudang = new ProductInGudangHandler(_unitOfWork).CreateOrEdit(requestproductingudang); var savehistoryproductingudang = new HistoryProductInGudangHandler(_unitOfWork).CreateOrEdit(requesthistoryproductingudang); } return(Json(new { Status = _response.Status }, JsonRequestBehavior.AllowGet)); }