コード例 #1
0
ファイル: PackagesController.cs プロジェクト: Shuvayu/DevBox
        public ActionResult CreatePackage(PackageViewModel packageViewModel)
        {
            AutoMapper.Mapper.CreateMap<PackageViewModel,Package>();
            var packageModel = AutoMapper.Mapper.Map<Package>(packageViewModel);

            var userName= User.Identity.GetUserName();
            var enetUser =Enumerable.First(userContracts.GetAll(), x => x.UserName == userName);

            packageModel.RegisteredBy = enetUser.UserId;
            packageModel.RegisteredAt = enetUser.DistributionCenterId;
            ViewBag.MedicineId = new SelectList(medicineContracts.GetAll(), "MedicineId", "MedicineName");

               packageModel= packagesContracts.Add(packageModel);
            if (!String.IsNullOrEmpty(packageModel.BarcodeId))
            {

                ViewBag.URL= Barcode.Encode(packageModel.BarcodeId, Server.MapPath("~/Images/"));
                ViewBag.URL = "/Images/" + packageModel.BarcodeId + ".jpg";
                TempData["Success"] = "Package Create : Barcode :" + packageModel.BarcodeId;
                ViewBag.Barcode = packageModel.BarcodeId;
                return View(packageViewModel);
            }
            else
            {
                TempData["Fail"] = "Error Creating the barcode";
               return RedirectToAction("CreatePackage");
            }
            return View();
        }
コード例 #2
0
ファイル: StockController.cs プロジェクト: Shuvayu/DevBox
        public ActionResult DiscardConfirm(PackageViewModel pvm)
        {
            var package= packagesContracts.UpdateStatus(pvm.BarcodeId, 4);
            if (package.PackageId > 0)
            {
                TempData["Success"] = "Discarded the package";
                return RedirectToAction("Index");

            }
            else
            {
                TempData["Fail"] = "Failed to Discard the package";
                return View("Index");

            }
        }
コード例 #3
0
ファイル: PackagesController.cs プロジェクト: Shuvayu/DevBox
 public ActionResult GetPackageByBarcode(string id)
 {
     AutoMapper.Mapper.CreateMap<Package, PackageViewModel>();
     AutoMapper.Mapper.CreateMap<Medicine,MedicineViewModel>();
     AutoMapper.Mapper.CreateMap<PackageStatus,PackageStatusViewModel>();
     AutoMapper.Mapper.CreateMap<PackageTransactions,PackageTransactionsViewModel>();
     var user = User.Identity.GetUserName();
     ;
     var package = Mapper.Map<PackageViewModel>(packagesContracts.GetInStockInCurrentDC(id, userContracts.GetcurrentUserDetails(user).DistributionCenterId));
     if (package==null)
     {
         package= new PackageViewModel();
         LoadViewBags();
         package.PackageId=-1;
         return Json(package);
     }
     else
     {
         var medicine = package.Medicine;
         medicine.Expiry = package.ExpiryDate.ToShortDateString();
         return Json(medicine);
     }
 }
コード例 #4
0
ファイル: PackagesController.cs プロジェクト: Shuvayu/DevBox
        public ActionResult SendPackageWithModel(PackageViewModel packageViewModel)
        {
            AutoMapper.Mapper.CreateMap<PackageViewModel, Package>();
            AutoMapper.Mapper.CreateMap<PackageStatusViewModel, PackageStatus>();
            AutoMapper.Mapper.CreateMap<MedicineViewModel, Medicine>();
            var package=Mapper.Map<Package>(packageViewModel);

             var id=   packagesContracts.SendPackage(package,User.Identity.GetUserName());
            if (id>0)
            {
                TempData["Success"] = "Sent the package";
                return Redirect("SendPackage");
            }
            else
            {
               LoadViewBags();
                TempData["Fail"] = "Failed to send the package";
                return View("SendPackage");
            }
        }
コード例 #5
0
ファイル: PackagesController.cs プロジェクト: Shuvayu/DevBox
        public ActionResult ReceivePackagewithModel(PackageViewModel packageViewModel)
        {
            var package = packagesContracts.Get(packageViewModel.BarcodeId);
            // Change current loc to this loc
            //Transit state
               var id= packagesContracts.ReceivePackage(package, User.Identity.GetUserName());
            if (id>0)
            {
                TempData["Success"] = "Received Package";
                return RedirectToAction("ReceivePackage");

            }
            else
            {
                TempData["Fail"] = "Failed to receive";
                return View("ReceivePackage");
            }
        }