Example #1
0
        public ActionResult Create([Bind(Include = "PackageID,WaybillID,PackageTypeID,PackageTypeSizeID,Description,ContentValue,CurrencyCode,Weight,Fee")] Package package)
        {
            //package.Weight = Math.Round(package.Weight, 1);
            bool isPackageTypeSizeEmpty = false;

            if (package.PackageTypeSizeID == 0)
            {
                isPackageTypeSizeEmpty = true;
            }
            if (ModelState.IsValid && isPackageTypeSizeEmpty == false)
            {
                package.Currency        = db.Currencies.Single(s => s.CurrencyCode == package.CurrencyCode);
                package.PackageType     = db.PackageTypes.Single(s => s.PackageTypeID == package.PackageTypeID);
                package.PackageTypeSize = db.PackageTypeSizes.Single(s => s.PackageTypeSizeID == package.PackageTypeSizeID);
                package.Shipment        = db.Shipments.Single(s => s.WaybillID == package.WaybillID);
                //package.Fee = CalculatePrice(package);
                db.Packages.Add(package);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CurrencyCode      = new SelectList(db.Currencies, "CurrencyCode", "CurrencyCode", package.CurrencyCode);
            ViewBag.PackageTypeID     = new SelectList(db.PackageTypes, "PackageTypeID", "Type", package.PackageTypeID);
            ViewBag.PackageTypeSizeID = new SelectList(db.PackageTypeSizes, "PackageTypeSizeID", "Description", package.PackageTypeSizeID);
            ViewBag.WaybillID         = new SelectList(db.Shipments, "WaybillID", "ReferenceNumber", package.WaybillID);
            return(View(package));
        }
        public async Task <ActionResult> EditPersonalProfile([Bind(Include = "ShippingAccountId,AccountType,UserName,PhoneNumber,Email,Building,Street,City,Province,PostalCode,CreditCardType,CreditCardNumber,CreditCardSecurityNumber,CardholderName,CreditCardExpiryMonth,CreditCardExpiryYear,FirstName,LastName")] PersonalShippingAccount model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            int?id = model.ShippingAccountId;

            user.PhoneNumber = model.PhoneNumber;
            user.Email       = model.Email;

            var result = await UserManager.UpdateAsync(user);

            if (!result.Succeeded)
            {
                AddErrors(result);
            }

            db.Entry(model).State = EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("Index", new { Message = ManageMessageId.EditProfileSuccess }));
        }
        public ActionResult Create([Bind(Include = "AddressId,AddressName,Building,Street,City,ProvinceCode,PostalCode")] Address address)
        {
            if ((string)Session["AddressType"] == "RecipientAddress")
            {
                address.isRecipientAddress = true;
            }
            else if ((string)Session["AddressType"] == "PickupAddress")
            {
                address.isRecipientAddress = false;
            }
            else
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (ModelState.IsValid)
            {
                address.ShippingAccountId = GetCurrentShippingAccountId();
                db.Addresses.Add(address);
                db.SaveChanges();
                return(RedirectToAction("Index", new { AddressType = (string)Session["AddressType"] }));
            }

            ViewBag.ShippingAccountId = new SelectList(db.ShippingAccounts, "ShippingAccountId", "Building", address.ShippingAccountId);
            return(View(address));
        }
 public ActionResult Edit([Bind(Include = "ShippingAccountId,Building,Street,City,ProvinceCode,PostalCode,Type,CardNumber,SecurityNumber,CardholderName,ExpiryMonth,ExpiryYear,PhoneNumber,EmailAddress,AccountNumber,ContactPersonName,CompanyName,DepartmentName")] BusinessShippingAccount businessShippingAccount)
 {
     if (ModelState.IsValid)
     {
         db.Entry(businessShippingAccount).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(businessShippingAccount));
 }
        public ActionResult Create([Bind(Include = "TrackingSystemRecordId,WaybillId,DateTimeOfRecord,Activity,Location,Remarks,DeliveredTo,DeliveredAt,Status")] TrackingSystemRecord trackingSystemRecord)
        {
            if (ModelState.IsValid)
            {
                db.TrackingSystemRecords.Add(trackingSystemRecord);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(trackingSystemRecord));
        }
        public ActionResult Create([Bind(Include = "PickupId,Type,Building,Street,City,ProvinceCode,PostalCode,PickupDateTime")] Pickup pickup)
        {
            if (ModelState.IsValid)
            {
                db.Pickups.Add(pickup);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pickup));
        }
        public ActionResult Create([Bind(Include = "DestinationID,City,CurrencyCode,ProvinceCode")] Destination destination)
        {
            if (ModelState.IsValid)
            {
                db.Destinations.Add(destination);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(destination));
        }
        public ActionResult Create([Bind(Include = "CurrencyCode,ExchangeRate")] Currency currency)
        {
            if (ModelState.IsValid)
            {
                db.Currencies.Add(currency);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(currency));
        }
Example #9
0
        public ActionResult Create([Bind(Include = "ShippingAccountId,Building,Street,City,ProvinceCode,PostalCode,Type,CardNumber,SecurityNumber,CardholderName,ExpiryMonth,ExpiryYear,PhoneNumber,EmailAddress,AccountNumber,FirstName,LastName")] PersonalShippingAccount personalShippingAccount)
        {
            if (ModelState.IsValid)
            {
                db.ShippingAccounts.Add(personalShippingAccount);
                db.SaveChanges();
                return(RedirectToAction("Home"));
            }

            return(View(personalShippingAccount));
        }
Example #10
0
        public ActionResult Create([Bind(Include = "PackageTypeID,Type,Description")] PackageType packageType)
        {
            if (ModelState.IsValid)
            {
                db.PackageTypes.Add(packageType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(packageType));
        }
        public ActionResult Create([Bind(Include = "ServiceTypeID,Type,CutoffTime,DeliveryTime")] ServiceType serviceType)
        {
            if (ModelState.IsValid)
            {
                db.ServiceTypes.Add(serviceType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(serviceType));
        }
Example #12
0
        public ActionResult Create([Bind(Include = "PickupId,PickupTime,IsImmediatePickup")] Pickup pickup)
        {
            if (ModelState.IsValid)
            {
                db.Pickups.Add(pickup);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pickup));
        }
        public ActionResult Create([Bind(Include = "InvoiceId,WaybillId,ShipDate,RecipientName,Origin,Destination,ServiceType,InvoiceAmount")] Invoice invoice)
        {
            if (ModelState.IsValid)
            {
                db.Invoices.Add(invoice);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(invoice));
        }
Example #14
0
        public ActionResult Create([Bind(Include = "WaybillId,ReerenceNumber,ServiceTypes,ShippedDate,DeliveredDate,RecipientName,NumberOfPackages,Origin,Destination,Status,ShippingAccountId")] Shipment shipment)
        {
            if (ModelState.IsValid)
            {
                db.Shipments.Add(shipment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(shipment));
        }
        public ActionResult Create([Bind(Include = "PackageId,PackageTypeSize,Description,Value,CustomerWeight,ActualWeight,PackageCost,WaybillId")] Package package)
        {
            if (ModelState.IsValid)
            {
                db.Packages.Add(package);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.WaybillId = new SelectList(db.Shipments, "WaybillId", "ReferenceNumber", package.WaybillId);
            return(View(package));
        }
Example #16
0
        public ActionResult Create([Bind(Include = "PackageTypeSizeID,Type,Description,PackageTypeID")] PackageTypeSize packageTypeSize)
        {
            if (ModelState.IsValid)
            {
                db.PackageTypeSizes.Add(packageTypeSize);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PackageTypeID = new SelectList(db.PackageTypes, "PackageTypeID", "Type", packageTypeSize.PackageTypeID);
            return(View(packageTypeSize));
        }
 public ActionResult Edit([Bind(Include = "ShippingAccountId,Building,Street,City,ProvinceCode,PostalCode,Type,CardNumber,SecurityNumber,CardholderName,ExpiryMonth,ExpiryYear,PhoneNumber,EmailAddress,AccountNumber,ContactPersonName,CompanyName,DepartmentName")] BusinessShippingAccount businessShippingAccount)
 {
     if (ModelState.IsValid)
     {
         businessShippingAccount.UserName        = User.Identity.Name; // newly added for User Profile
         db.Entry(businessShippingAccount).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("DisplayInfo", "Account"));  // newly added for User Profile
         //return RedirectToAction("Index");     //original
     }
     return(View(businessShippingAccount));
 }
Example #18
0
        public ActionResult Create([Bind(Include = "DestinationID,City,ProvinceCode,CurrencyCode")] Destination destination)
        {
            if (ModelState.IsValid)
            {
                db.Destinations.Add(destination);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CurrencyCode = new SelectList(db.Currencies, "CurrencyCode", "CurrencyCode", destination.CurrencyCode);
            return(View(destination));
        }
        public ActionResult Create([Bind(Include = "WaybillId,Pickuptype,Pickuplocation,PickupDateTime")] PickupInforation pickupInforation)
        {
            if (ModelState.IsValid)
            {
                pickupInforation.WaybillId = int.Parse(Session["WaybillId"].ToString());
                db.PickupInforations.Add(pickupInforation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.WaybillId = new SelectList(db.Shipments, "WaybillId", "ReferenceNumber", pickupInforation.WaybillId);
            return(View("Index", "Shipments"));
        }
Example #20
0
        public ActionResult Create([Bind(Include = "ServicePackageFeeID,Fee,MinimumFee,PackageTypeID,ServiceTypeID")] ServicePackageFee servicePackageFee)
        {
            if (ModelState.IsValid)
            {
                db.ServicePackageFees.Add(servicePackageFee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PackageTypeID = new SelectList(db.PackageTypes, "PackageTypeID", "Type", servicePackageFee.PackageTypeID);
            ViewBag.ServiceTypeID = new SelectList(db.ServiceTypes, "ServiceTypeID", "Type", servicePackageFee.ServiceTypeID);
            return(View(servicePackageFee));
        }
        public ActionResult ChangePenalty(decimal?newPenalty)
        {
            if (newPenalty == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            List <ServicePackageFee> ServicePackageFeeList = db.ServicePackageFees.ToList();

            foreach (ServicePackageFee servicePackageFee in ServicePackageFeeList)
            {
                servicePackageFee.Penalty         = (decimal)newPenalty;
                db.Entry(servicePackageFee).State = EntityState.Modified;
            }
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit([Bind(Include = "ccType,ccNumber,ccSecurityNumber,ccHolderName,ccExpirationMonth,ccExpirationYear,ShippingAccountID,Building,Street,City,Province,PostalCode,PhoneNumber,Email,ContactPersonName,CompanyName,DepartmentName")] BusinessShippingAccount businessShippingAccount)
        {
            if (ModelState.IsValid)
            {
                //db.Entry(businessShippingAccount).State = EntityState.Modified;
                //db.SaveChanges();

                var ent = (BusinessShippingAccount)db.ShippingAccounts.Find(businessShippingAccount.ShippingAccountID);
                ent.CompanyName       = businessShippingAccount.CompanyName;
                ent.DepartmentName    = businessShippingAccount.DepartmentName;
                ent.ContactPersonName = businessShippingAccount.ContactPersonName;
                ent.PhoneNumber       = businessShippingAccount.PhoneNumber;
                ent.Email             = businessShippingAccount.Email;
                ent.Building          = businessShippingAccount.Building;
                ent.Street            = businessShippingAccount.Street;
                ent.City              = businessShippingAccount.City;
                ent.Province          = businessShippingAccount.Province;
                ent.PostalCode        = businessShippingAccount.PostalCode;
                ent.ccType            = businessShippingAccount.ccType;
                ent.ccNumber          = businessShippingAccount.ccNumber;
                ent.ccSecurityNumber  = businessShippingAccount.ccSecurityNumber;
                ent.ccHolderName      = businessShippingAccount.ccHolderName;
                ent.ccExpirationMonth = businessShippingAccount.ccExpirationMonth;
                ent.ccExpirationYear  = businessShippingAccount.ccExpirationYear;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(businessShippingAccount));
        }
        public ActionResult Edit([Bind(Include = "ShippingAccountID,FirstName,LastName,PhoneNumber,Email,Building,Street,City,Province,PostalCode,ccType,ccNumber,ccSecurityNumber,ccHolderName,ccExpirationMonth,ccExpirationYear")] PersonalShippingAccount personalShippingAccount)
        {
            if (ModelState.IsValid)
            {
                //db.Entry(personalShippingAccount).State = EntityState.Modified;
                //db.SaveChanges();

                var ent = (PersonalShippingAccount)db.ShippingAccounts.Find(personalShippingAccount.ShippingAccountID);
                ent.FirstName         = personalShippingAccount.FirstName;
                ent.LastName          = personalShippingAccount.LastName;
                ent.PhoneNumber       = personalShippingAccount.PhoneNumber;
                ent.Email             = personalShippingAccount.Email;
                ent.Building          = personalShippingAccount.Building;
                ent.Street            = personalShippingAccount.Street;
                ent.City              = personalShippingAccount.City;
                ent.Province          = personalShippingAccount.Province;
                ent.PostalCode        = personalShippingAccount.PostalCode;
                ent.ccType            = personalShippingAccount.ccType;
                ent.ccNumber          = personalShippingAccount.ccNumber;
                ent.ccSecurityNumber  = personalShippingAccount.ccSecurityNumber;
                ent.ccHolderName      = personalShippingAccount.ccHolderName;
                ent.ccExpirationMonth = personalShippingAccount.ccExpirationMonth;
                ent.ccExpirationYear  = personalShippingAccount.ccExpirationYear;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(personalShippingAccount));
        }
        public ActionResult Create([Bind(Include = "PickUpLocationID,PickUpNickName,PickUpBuilding,PickUpStreet,PickUpCity,PickUpProvinceCode,PickUpPostalCode")] PickUpLocationViewModel pickUpLocationViewModel)
        {
            if (ModelState.IsValid)
            {
                PickUpLocation pickUpLocation = new PickUpLocation(pickUpLocationViewModel.PickUpLocationID,
                                                                   pickUpLocationViewModel.PickUpNickName, pickUpLocationViewModel.PickUpBuilding, pickUpLocationViewModel.PickUpStreet,
                                                                   pickUpLocationViewModel.PickUpCity, pickUpLocationViewModel.PickUpProvinceCode, pickUpLocationViewModel.PickUpPostalCode);

                pickUpLocation.PickUpProvinceCode = GetProvince(pickUpLocation.PickUpCity);
                db.PickUpLocations.Add(pickUpLocation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pickUpLocationViewModel));
        }
        public ActionResult Create([Bind(Include = "PickupLocationID,ShippingAccountID,Nickname,Building,Street,City,Province,PostalCode")] PickupLocation pickupLocation)
        {
            if (ModelState.IsValid)
            {
                var    userQuery = from s in db.ShippingAccounts select new { s.ShippingAccountID, s.UserName };
                string username  = User.Identity.GetUserName();
                userQuery = userQuery.Where(s => s.UserName == username);
                int account = userQuery.ToList()[0].ShippingAccountID;

                pickupLocation.ShippingAccountID = account;
                db.PickupLocations.Add(pickupLocation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ShippingAccountID = new SelectList(db.ShippingAccounts, "ShippingAccountID", "UserName", pickupLocation.ShippingAccountID);
            return(View(pickupLocation));
        }
Example #26
0
 public ActionResult Edit([Bind(Include = "ShippingAccountId,AccountType,UserName,PhoneNumber,Email,Building,Street,City,Province,PostalCode,CreditCardType,CreditCardNumber,CreditCardSecurityNumber,CardholderName,CreditCardExpiryMonth,CreditCardExpiryYear,FirstName,LastName")] PersonalShippingAccount personalShippingAccount)
 {
     if (ModelState.IsValid)
     {
         db.Entry(personalShippingAccount).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "Home"));
     }
     return(View(personalShippingAccount));
 }
Example #27
0
        public ActionResult Create([Bind(Include = "RecipientAddressID,NickName,RecipientName,RecipientShippingAccountId,CompanyName,DepartmentName,Building,Street,City,ProvinceCode,PostalCode,RecipientPhoneNumber,RecipientEmail")] RecipientAddressViewModel recipientAddressViewModel)
        {
            if (ModelState.IsValid)
            {
                RecipientAddress recipientAddress = new RecipientAddress(recipientAddressViewModel.RecipientAddressID,
                                                                         recipientAddressViewModel.NickName, recipientAddressViewModel.RecipientName, recipientAddressViewModel.RecipientShippingAccountId,
                                                                         recipientAddressViewModel.CompanyName, recipientAddressViewModel.DepartmentName,
                                                                         recipientAddressViewModel.Building, recipientAddressViewModel.Street, recipientAddressViewModel.City, recipientAddressViewModel.ProvinceCode,
                                                                         recipientAddressViewModel.PostalCode, recipientAddressViewModel.RecipientPhoneNumber, recipientAddressViewModel.RecipientEmail
                                                                         );

                recipientAddress.ProvinceCode = GetProvince(recipientAddress.City);
                db.RecipientAddresses.Add(recipientAddress);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(recipientAddressViewModel));
        }
Example #28
0
        public ActionResult TrackingSystemCreate([Bind(Include = "TrackingStatementID,WaybillID,DateTime,Description,Location,Remarks")] TrackingStatement ts)
        {
            if (ModelState.IsValid)
            {
                db.TrackingStatements.Add(ts);
                db.SaveChanges();
                return(RedirectToAction("TrackingSystem"));
            }

            return(View(ts));
        }
Example #29
0
        public ActionResult Create([Bind(Include = "WaybillId,ReferenceNumber,ServiceType,ShippedDate,DeliveredDate,RecipientName,NumberOfPackages,Origin,Destination,Status,ShippingAccountId,RecipientPhoneNumber,DeliveryAddress,NotificationToSender,NotificationToRecipient")] Shipment shipment)
        {
            if (ModelState.IsValid)
            {
                shipment.ShippedDate   = new DateTime(2017, 05, 11);
                shipment.DeliveredDate = new DateTime(2017, 05, 11);

                shipment.Status            = "Created";
                shipment.ShippingAccountId = db.ShippingAccounts.Where(s => s.UserName == User.Identity.Name).Select(s => s.ShippingAccountId).Single();


                shipment.NumberOfPackages = 0;
                db.Shipments.Add(shipment);
                db.SaveChanges();
                Session["WaybillId"] = shipment.WaybillId;

                return(RedirectToAction("Create", "Packages"));
            }

            // ViewBag.ServiceTypeID  = new SelectList(db.ServiceTypes, "ServiceTypeID", "Type", shipment.ServiceTypeID);
            return(View(shipment));
        }
Example #30
0
 public ActionResult Edit([Bind(Include = "UserName,ShippingAccountId,Building,Street,City,ProvinceCode,PostalCode,CreditCardType,CreditCardNumber,CreditCardSecurityNumber,CreditCardCardholderName,CreditCardExpiryMonth,CreditCardExpiryYear,PhoneNumber,Email,ContactPersonName,CompanyName,DepartmentName")] BusinessShippingAccount businessShippingAccount)
 {
     if (businessShippingAccount.UserName != User.Identity.Name)
     {
         return(HttpNotFound());
     }
     if (ModelState.IsValid)
     {
         db.Entry(businessShippingAccount).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "Home"));
     }
     return(View(businessShippingAccount));
 }