public ActionResult SaveImportTrackToSession(ImportTrackModel model)
 {
     ImportTrackSession.CreateDate = model.CreateDate;
     ImportTrackSession.Note       = model.Note;
     ImportTrackSession.StorageId  = model.StorageId;
     return(Json(true));
 }
        public ActionResult ListImportDetail(int id)
        {
            var model = new ImportTrackModel
            {
                ImportTrackId = id
            };

            return(View("_ListImportDetail", model));
        }
        //
        // GET: /Administrator/MyOffice/

        public ActionResult Index()
        {
            var storages = _storageRepository.Search("").Where(p => WorkContext.MyStorages.Contains(p.StorageId)).ToList();
            var model    = new ImportTrackModel
            {
                Storages = storages
            };

            return(View(model));
        }
        public virtual ActionResult Edit(int id)
        {
            var products = _productRepository.Search("").ToList();
            var entity   = Repository.GetById(id);
            var model    = new ImportTrackModel
            {
                ImportTrackId = entity.ImportTrackId,
                Note          = entity.Note,
                Products      = products,
                CreateDate    = entity.CreateDate
            };

            return(View("Edit", model));
        }
 public virtual ActionResult Save(ImportTrackModel model)
 {
     if (model.ImportTrackId <= 0) //Create News
     {
         if (!ModelState.IsValid)
         {
             var products = _productRepository.Search("").ToList();
             var storages = _storageRepository.Search("").ToList();
             model.Products = products;
             model.Storages = storages;
             return(View("Create", model));
         }
         if (!ImportDetails.Any())
         {
             SetErrorNotification(string.Format("Bạn chưa có sản phẩm nào."));
             return(RedirectToAction("Create", new { area = "Administrator" }));
         }
         var entity = new ImportTrack
         {
             IsDeleted     = false,
             CreateDate    = model.CreateDate,
             CreateUserId  = WorkContext.CurrentUserId,
             Note          = model.Note,
             ToStorageId   = model.StorageId,
             ImportDetails = new List <ImportDetail>()
         };
         foreach (var orderDetailModel in ImportDetails)
         {
             entity.ImportDetails.Add(new ImportDetail
             {
                 Amount    = orderDetailModel.Amount,
                 ProductId = orderDetailModel.ProductId,
                 Note      = orderDetailModel.Note,
                 IsDeleted = false
             });
         }
         using (UnitOfWork)
         {
             Repository.Insert(entity);
         }
     }
     ImportTrackSession = new ImportTrackModel();
     //Save success
     this.SetSuccessNotification(string.Format("{0} đã được lưu thành công.", "Nhập kho"));
     return(RedirectToAction("Create", new { area = "Administrator" }));
 }
        public ActionResult Create(int?mode, bool?blank)
        {
            if (!blank.HasValue || blank.Value)
            {
                ImportDetails = new List <ImportDetailModel>();
            }
            var storages = _storageRepository.Search("").Where(p => WorkContext.MyStorages.Contains(p.StorageId)).ToList();
            var model    = new ImportTrackModel
            {
                CreateDate = ImportTrackSession.CreateDate != DateTime.MinValue ? ImportTrackSession.CreateDate : DateTime.Now,
                StorageId  = ImportTrackSession.StorageId,
                Note       = ImportTrackSession.Note,
                Mode       = mode,
                Storages   = storages
            };

            return(View(model));
        }