Esempio n. 1
0
 public ActionResult ChangeStoreItem(ConfirmStoreItemViewModel model, string orderNo)
 {
     if (!ModelState.IsValid)
     {
         foreach (var item in model.Items)
         {
             item.ProductResource = new ResourceViewModel().FromEntity<ResourceViewModel>(_orderRepo.Context.Set<ResourceEntity>().Where(r => r.SourceType == (int)SourceType.Product && r.SourceId == item.ProductId).FirstOrDefault());
            // item.UPCCode = Context.Set<ProductCode2StoreCodeEntity>().Where(pm => pm.StoreId == item.StoreId && pm.ProductId == item.ProductId && pm.Status != (int)DataStatus.Deleted)
             //       .Select(pm => pm.StoreProductCode).FirstOrDefault();
             item.Brand = new BrandViewModel().FromEntity<BrandViewModel>(Context.Set<BrandEntity>().Find(item.BrandId));
             item.Store = new StoreViewModel().FromEntity<StoreViewModel>(Context.Set<StoreEntity>().Find(item.StoreId));
         }
         ViewBag.OrderNo = orderNo;
         return View(model);
     }
     var orderEntity = _orderRepo.Get(o => o.OrderNo == orderNo).FirstOrDefault();
     string errorMsg;
     if (!OrderViewModel.IsAuthorized(orderEntity.StoreId, orderEntity.BrandId, out errorMsg))
     {
         ViewBag.OrderNo = orderNo;
         ModelState.AddModelError(string.Empty, errorMsg);
         return View(model);
     }
     using (var ts = new TransactionScope())
     {
         foreach (var item in model.Items)
         {
             var itemEntity = _orderItemRepo.Find(item.Id);
             itemEntity.StoreItemNo = item.StoreItemNo;
             itemEntity.StoreItemDesc = item.StoreItemDesc;
             itemEntity.ProductDesc = item.ProductDesc;
             itemEntity.SalesPerson = CurrentUser.NickName;
             itemEntity.UpdateDate = DateTime.Now;
             itemEntity.UpdateUser = CurrentUser.CustomerId;
             _orderItemRepo.Update(itemEntity);
         }
         orderEntity.Status = (int)OrderStatus.AgentConfirmed;
         orderEntity.UpdateDate = DateTime.Now;
         orderEntity.UpdateUser = CurrentUser.CustomerId;
         _orderRepo.Update(orderEntity);
         _orderLogRepo.Insert(new OrderLogEntity()
         {
             OrderNo = orderNo,
             CreateDate = DateTime.Now,
             CreateUser = CurrentUser.CustomerId,
             CustomerId = CurrentUser.CustomerId,
             Operation = "专柜确认商品编码。",
             Type = (int)OrderOpera.FromOperator
         });
         ts.Complete();
     }
     return RedirectToAction("Details", new { OrderNo = orderNo });
 }
Esempio n. 2
0
 public ActionResult ChangeStoreItem(string orderNo)
 {
     var order = _orderRepo.Context.Set<OrderItemEntity>().Where(o => o.OrderNo == orderNo)
         .GroupJoin(_orderRepo.Context.Set<ResourceEntity>().Where(r => r.Status != (int)DataStatus.Deleted && r.SourceType == (int)SourceType.Product),
             o => o.ProductId,
             i => i.SourceId,
             (o, i) => new { O = o, R = i.FirstOrDefault() });
     var model = new ConfirmStoreItemViewModel();
     model.Items = order.ToList().Select(o => new OrderItemViewModel().FromEntity<OrderItemViewModel>(o.O, p =>
     {
         p.ProductResource = new ResourceViewModel().FromEntity<ResourceViewModel>(o.R);
        // p.UPCCode = Context.Set<ProductCode2StoreCodeEntity>().Where(pm => pm.StoreId == o.O.StoreId && pm.ProductId == o.O.ProductId && pm.Status != (int)DataStatus.Deleted)
         //            .Select(pm => pm.ExPId).FirstOrDefault();
         p.Brand = new BrandViewModel().FromEntity<BrandViewModel>(Context.Set<BrandEntity>().Find(p.BrandId));
         p.Store = new StoreViewModel().FromEntity<StoreViewModel>(Context.Set<StoreEntity>().Find(p.StoreId));
         if (string.IsNullOrEmpty(p.StoreItemNo))
         {
             var sectionEntity = Context.Set<SectionEntity>().Where(s => s.StoreId == o.O.StoreId 
                     && s.BrandId == o.O.BrandId
                     && s.Status == (int)DataStatus.Normal)
                             .FirstOrDefault();
             if (sectionEntity != null)
                 p.StoreItemNo = sectionEntity.StoreCode;
         }
     }));
     ViewBag.OrderNo = orderNo;
     return View(model);
 }