Exemple #1
0
        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());
        }
        public void CreatePackageTest()
        {
            package.PackageId    = 100;
            package.RegisteredAt = 1;
            package.RegisteredBy = 1;

            packageContract.Add(package);
        }