コード例 #1
0
 public Operation Delete(SlsReplacementDetail objSlsReplacementDetail)
 {
     throw new NotImplementedException();
 }
コード例 #2
0
 public void Add(SlsReplacementDetail objSlsReplacementDetail)
 {
     _SalesReplacementDetailRepository.Add(objSlsReplacementDetail);
 }
コード例 #3
0
        public static SlsReplacementDetail MapToSlsReplacementDetail(SlsReplacementDetailViewModel obj)
        {
            SlsReplacementDetail model = new SlsReplacementDetail();

               model.Id = obj.Id;

               model.SlsReplacementId = obj.SlsReplacementId;
               model.SlsProductId = obj.SlsProductId;
               model.Quantity = obj.Quantity;
               model.SlsUnitId = obj.SlsUnitId;

               model.AdjustedAmount = obj.AdjustedAmount;
               model.Reason = obj.Reason;

               return model;
        }
コード例 #4
0
        public Operation Update(SlsReplacementDetail objSlsReplacementDetail)
        {
            Operation objOperation = new Operation { Success = true, OperationId = objSlsReplacementDetail.Id };
               _SalesReplacementDetailRepository.Update(objSlsReplacementDetail);

               try
               {
               _UnitOfWork.Commit();
               }
               catch (Exception)
               {
               objOperation.Success = false;

               }
               return objOperation;
        }
コード例 #5
0
        public Operation Save(SlsReplacementDetail objSlsReplacementDetail)
        {
            Operation objOperation = new Operation { Success = true };

               long Id = _SalesReplacementDetailRepository.AddEntity(objSlsReplacementDetail);
               objOperation.OperationId = Id;

               try
               {
               _UnitOfWork.Commit();
               }
               catch (Exception ex)
               {
               objOperation.Success = false;
               }
               return objOperation;
        }
コード例 #6
0
        //[HttpGet]
        //public ActionResult GetAllSalesReplacementDetails(int SlsReplacementId)
        //{
        //    //DatabaseFactory dbfactory = new DatabaseFactory();
        //    //var list = new SalesOrderService(new SalesOrderRepository(dbfactory),
        //    //    new SalesOrderDetailRepository(dbfactory),
        //    //    new SalesOrderApprovalRepository(dbfactory),
        //    //    new UnitOfWork(dbfactory)).GetAll();
        //    var list = _SalesReplacementDetailService.GetAll();
        //    if(list != null && list.Count() > 0)
        //    {
        //        list = list.Where(i => i.SlsReplacementId == SlsReplacementId).ToList();
        //    }
        //    return Json(list, JsonRequestBehavior.AllowGet);
        //}
        public ActionResult Save(SlsReplacementViewModel slsReplacement)
        {
            int companyId = Convert.ToInt32(Session["companyId"]);
            int userId = Convert.ToInt32(Session["userId"]);
            var dbfactory = new DatabaseFactory();

            Operation objOperation = new Operation { Success = false };
            if (ModelState.IsValid)
            {
                if (slsReplacement.Id == 0)
                {
                    if ((bool)Session["Add"])
                    {
                        slsReplacement.SecCompanyId = companyId;
                        slsReplacement.CreatedBy = userId;
                        slsReplacement.CreatedDate = DateTime.Now;
                        //invDamage.InvDamageDetails = null;
                        objOperation = _SalesReplacementService.Save(slsReplacement);

                        //int SalesReplacementId = Convert.ToInt32(objOperation.OperationId);
                        //List<SlsReplacementDetail> slsReplacementDetail = slsReplacement.SlsReplacementDetails.ToList();
                        ////slsReplacement.SalesOrderDetails;
                        //foreach (var item in slsReplacementDetail)
                        //{
                        //    SlsReplacementDetail objSlsReplacementDetail = _SalesReplacementDetailService.GetById(item.Id);
                        //    if (objSlsReplacementDetail != null)
                        //    {
                        //        objSlsReplacementDetail.SlsReplacementId= slsReplacement.Id;
                        //        objSlsReplacementDetail.SlsProductId = item.SlsProductId;
                        //        objSlsReplacementDetail.Quantity = item.Quantity;
                        //        objSlsReplacementDetail.Reason = item.Reason;
                        //        objSlsReplacementDetail.SlsUnitId = item.SlsUnitId;
                        //        _SalesReplacementDetailService.Update(objSlsReplacementDetail);
                        //    }
                        //    else
                        //    {
                        //        objSlsReplacementDetail = new SlsReplacementDetail();
                        //        objSlsReplacementDetail.SlsReplacementId = SalesReplacementId;
                        //        objSlsReplacementDetail.SlsProductId = item.SlsProductId;
                        //        objSlsReplacementDetail.Quantity = item.Quantity;
                        //        objSlsReplacementDetail.Reason = item.Reason;
                        //        objSlsReplacementDetail.SlsUnitId = item.SlsUnitId;
                        //        _SalesReplacementDetailService.Save(objSlsReplacementDetail);
                        //    }

                        //}

                    }

                }
                else
                {
                    if ((bool)Session["Edit"])
                    {
                        slsReplacement.SecCompanyId = companyId;
                        slsReplacement.ModifiedBy = userId;
                        slsReplacement.ModifiedDate = DateTime.Now;
                        objOperation = _SalesReplacementService.Update(slsReplacement);

                        List<SlsReplacementDetail> slsReplacementDetail = new List<SlsReplacementDetail>();
                        if (slsReplacement.SlsReplacementDetailVMs != null && slsReplacement.SlsReplacementDetailVMs.Count() > 0)
                        {
                            foreach (var detailVM in slsReplacement.SlsReplacementDetailVMs)
                            {
                                //make VMDetail from Detail model
                                var detail = SlsReplacementDetailMapVMToModel.MapToSlsReplacementDetail(detailVM);
                                slsReplacementDetail.Add(detail);
                            }
                        }

                        //slsReplacement.SalesOrderDetails;
                        foreach (var item in slsReplacementDetail)
                        {
                            SlsReplacementDetail objSlsReplacementDetail = _SalesReplacementDetailService.GetById(item.Id);
                            if (objSlsReplacementDetail != null)
                            {
                                objSlsReplacementDetail.SlsReplacementId = slsReplacement.Id;
                                objSlsReplacementDetail.SlsProductId = item.SlsProductId;
                                objSlsReplacementDetail.AdjustedAmount= item.AdjustedAmount;
                                objSlsReplacementDetail.Quantity = item.Quantity;
                                objSlsReplacementDetail.Reason = item.Reason;
                                objSlsReplacementDetail.SlsUnitId = item.SlsUnitId;
                                _SalesReplacementDetailService.Update(objSlsReplacementDetail);
                            }
                            else
                            {
                                objSlsReplacementDetail = new SlsReplacementDetail();
                                objSlsReplacementDetail.SlsReplacementId = slsReplacement.Id;
                                objSlsReplacementDetail.SlsProductId = item.SlsProductId;
                                objSlsReplacementDetail.AdjustedAmount = item.AdjustedAmount;
                                objSlsReplacementDetail.Quantity = item.Quantity;
                                objSlsReplacementDetail.Reason = item.Reason;
                                objSlsReplacementDetail.SlsUnitId = item.SlsUnitId;
                                _SalesReplacementDetailService.Save(objSlsReplacementDetail);
                            }

                        }

                    }

                }

                //objOperation = _IDamageService.Commit();
            }

            return Json(objOperation, JsonRequestBehavior.DenyGet);
        }