コード例 #1
0
        private RFQDetail getEntityByModel(RFQDetailModel model)
        {
            if (model == null) return null;
            RFQDetail entity = new RFQDetail();

            entity.Id = model.Id;
            entity.ItemId = model.ItemId;
            entity.Quantity = model.Quantity;
            entity.RFQId = model.RFQId;
            entity.TargetPrice = model.TargetPrice;
            
            if (model.Id == 0)
            {
                entity.CreateBy = AuthenticationHelper.UserId;
                entity.CreateDate = DateTime.Now;
            }
            else
            {
                entity.CreateBy = model.CreateBy;
                entity.CreateDate = model.CreateDate;
            }

            entity.UpdateBy = AuthenticationHelper.UserId;
            entity.UpdateDate = DateTime.Now;
            return entity;
        }
コード例 #2
0
        public ActionResult AddNewInLine(RFQDetailModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (SessionHelper.RFQ != null)
                    {
                        if (SessionHelper.RFQ.RFQDetail != null && SessionHelper.RFQ.RFQDetail.Count() > 0)
                            model.Id = SessionHelper.RFQ.RFQDetail.LastOrDefault().Id + 1;
                        else
                            model.Id = 1;
                    }
                    else
                        model.Id = 1;

                    RFQModel rfq = SessionHelper.RFQ;
                    rfq.RFQDetail.Add(model);
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
                ViewData["EditError"] = "Please, correct all errors.";
            return PartialView("_Detail", getRFQDetail());
        }
コード例 #3
0
 public ActionResult UpdateInLine(RFQDetailModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             RFQModel rfq = SessionHelper.RFQ;
             rfq.RFQDetail.FirstOrDefault(x => x.Id == model.Id).ItemId = model.ItemId;
             rfq.RFQDetail.FirstOrDefault(x => x.Id == model.Id).Quantity = model.Quantity;
             rfq.RFQDetail.FirstOrDefault(x => x.Id == model.Id).TargetPrice = model.TargetPrice;
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
         ViewData["EditError"] = "Please, correct all errors.";
     return PartialView("_Detail", getRFQDetail());
 }