Example #1
0
        public virtual ActionResult Save(ExportTrackModel myOfficeModel)
        {
            if (myOfficeModel.ExportTrackId <= 0) //Create News
            {
                if (!ModelState.IsValid)
                {
                    var offices  = _myOfficeRepository.Search("").Where(p => WorkContext.MyOffices.Contains(p.MyOfficeId)).ToList();
                    var products = _productRepository.Search("").ToList();
                    var users    = _userRepository.Search("").ToList();
                    var storages = _storageRepository.Search("").Where(p => WorkContext.MyStorages.Contains(p.StorageId)).ToList();
                    myOfficeModel.MyOffices = offices;
                    myOfficeModel.Products  = products;
                    myOfficeModel.Users     = users;
                    myOfficeModel.Storages  = storages;
                    return(View("Create", myOfficeModel));
                }
                var myOffice = new ExportTrack
                {
                    IsDeleted      = false,
                    CreateDate     = DateTime.Now,
                    CreateUserId   = WorkContext.CurrentUserId,
                    Note           = myOfficeModel.Note,
                    MyOfficeId     = myOfficeModel.MyOfficeId,
                    ReceivedUserId = myOfficeModel.ReceivedUserId
                };
                using (UnitOfWork)
                {
                    Repository.Insert(myOffice);
                }
            }
            else //Edit user
            {
                if (!ModelState.IsValid)
                {
                    var offices  = _myOfficeRepository.Search("").Where(p => WorkContext.MyOffices.Contains(p.MyOfficeId)).ToList();
                    var products = _productRepository.Search("").ToList();
                    var users    = _userRepository.Search("").ToList();
                    var storages = _storageRepository.Search("").Where(p => WorkContext.MyStorages.Contains(p.StorageId)).ToList();
                    myOfficeModel.MyOffices = offices;
                    myOfficeModel.Products  = products;
                    myOfficeModel.Users     = users;
                    myOfficeModel.Storages  = storages;
                    return(View("Edit", myOfficeModel));
                }

                var myOffice = Repository.GetById(myOfficeModel.ExportTrackId);
                myOffice.Note           = myOfficeModel.Note;
                myOffice.MyOfficeId     = myOfficeModel.MyOfficeId;
                myOffice.ReceivedUserId = myOfficeModel.ReceivedUserId;
                using (UnitOfWork)
                {
                    Repository.Update(myOffice);
                }
            }

            //Save success
            this.SetSuccessNotification(string.Format("{0} đã được lưu thành công.", "Xuất kho"));
            return(RedirectToAction("Index", new { area = "Administrator" }));
        }
Example #2
0
        public ActionResult ListExportDetail(int id)
        {
            var model = new ExportTrackModel
            {
                ExportTrackId = id
            };

            return(View("_ListExportDetail", model));
        }
Example #3
0
        public ActionResult Create()
        {
            var offices  = _myOfficeRepository.Search("").Where(p => WorkContext.MyOffices.Contains(p.MyOfficeId)).ToList();
            var products = _productRepository.Search("").ToList();
            var users    = _userRepository.Search("").ToList();
            var storages = _storageRepository.Search("").Where(p => WorkContext.MyStorages.Contains(p.StorageId)).ToList();
            var model    = new ExportTrackModel {
                MyOffices = offices, Products = products, Users = users, Storages = storages
            };

            return(View(model));
        }
Example #4
0
        //
        // GET: /Administrator/MyOffice/

        public ActionResult Index()
        {
            var customers = _customerRepository.Search("").Where(p => WorkContext.MyOffices.Contains(p.MyOfficeId)).ToList();
            var offices   = _myOfficeRepository.Search("").Where(p => WorkContext.MyOffices.Contains(p.MyOfficeId)).ToList();
            var products  = _productRepository.Search("").ToList();
            var model     = new ExportTrackModel
            {
                Customers = customers,
                MyOffices = offices,
                Products  = products
            };

            return(View(model));
        }
Example #5
0
        public virtual ActionResult Edit(int id)
        {
            var offices  = _myOfficeRepository.Search("").Where(p => WorkContext.MyOffices.Contains(p.MyOfficeId)).ToList();
            var products = _productRepository.Search("").ToList();
            var users    = _userRepository.Search("").ToList();
            var storages = _storageRepository.Search("").Where(p => WorkContext.MyStorages.Contains(p.StorageId)).ToList();
            var entity   = Repository.GetById(id);
            var model    = new ExportTrackModel()
            {
                ExportTrackId = entity.ExportTrackId,
                Note          = entity.Note,
                MyOfficeId    = entity.MyOfficeId,
                MyOffices     = offices,
                Products      = products,
                Users         = users,
                Storages      = storages
            };

            return(View("Edit", model));
        }