Exemplo n.º 1
0
        private JsonResult EditData(POViewModel model)
        {
            if (model.CheckCode != model.PurchaseOrder.vPOID)
            {
                if (_service.ExistedCode(model.PurchaseOrder.vPOID))
                {
                    return(Json(new { result = Constants.DuplicateCode, mRf = (Convert.ToInt32(_service.GetAutoPoCode()) + 1).ToString(CultureInfo.InvariantCulture) }));
                }
            }

            var entity = _service.GetByKey(model.PurchaseOrder.Id);

            if (!Convert.ToBase64String(model.PurchaseOrder.Timestamp).Equals(Convert.ToBase64String(entity.Timestamp)))
            {
                return(Json(new { result = Constants.DataJustChanged }));
            }

            try
            {
                var now = DateTime.Now;
                entity.vProjectID = model.PurchaseOrder.vProjectID;
                //entity.bSupplierID = model.PurchaseOrder.bSupplierID;
                entity.bPOTypeID = model.PurchaseOrder.bPOTypeID;
                //entity.bCurrencyTypeID = model.PurchaseOrder.bCurrencyTypeID;
                //entity.dPODate = model.PurchaseOrder.dPODate;
                //entity.fPOTotal = model.PurchaseOrder.fPOTotal;
                entity.vRemark              = model.PurchaseOrder.vRemark;
                entity.vPriceEval           = model.PurchaseOrder.vPriceEval;
                entity.vQuanlityEval        = model.PurchaseOrder.vQuanlityEval;
                entity.vDeliveryEval        = model.PurchaseOrder.vDeliveryEval;
                entity.vConformancyToV3Eval = model.PurchaseOrder.vConformancyToV3Eval;
                entity.vFromCC              = model.PurchaseOrder.vFromCC;
                entity.vFromContact         = model.PurchaseOrder.vFromContact;
                entity.vFromTel             = model.PurchaseOrder.vFromTel;
                entity.vFromFax             = model.PurchaseOrder.vFromFax;
                entity.vTermOfPayment       = model.PurchaseOrder.vTermOfPayment;
                entity.iExample             = model.PurchaseOrder.iExample;
                //entity.vPOStatus = model.PurchaseOrder.vPOStatus;
                entity.vLocation    = model.PurchaseOrder.vLocation;
                entity.dDeliverDate = model.PurchaseOrder.dDeliverDate;
                //entity.iStore = model.PurchaseOrder.iStore;
                entity.iPayment  = model.PurchaseOrder.iPayment;
                entity.iModified = model.LoginId;
                entity.dModified = now;
                _service.Update(entity, model.ListPoDetailData, model.LstDeleteDetailItem);

                return(Json(new { result = Constants.Success }));
            }
            catch (Exception e)
            {
                Log.Error("Update PE!", e);
                return(Json(new { result = Constants.UnSuccess }));
            }
        }
Exemplo n.º 2
0
 public HttpResponseMessage Update(HttpRequestMessage request, POViewModel poVM)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (!ModelState.IsValid)
         {
             response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
         }
         else
         {
             var dbPO = _poService.GetByID(poVM.ID);
             dbPO.UpdatePO(poVM);
             _poService.Update(dbPO);
             _poService.Save();
             var responseData = Mapper.Map <PO, POViewModel>(dbPO);
             response = request.CreateResponse(HttpStatusCode.Created, responseData);
         }
         return response;
     }));
 }