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 }));
        }
コード例 #2
0
        public ActionResult Edit([Bind(Include = "PackageID,WaybillID,PackageTypeSizeID,Description,ContentValue,CurrencyCode,Weight,Fee,PackageTypeID")] Package package)
        {
            if (ModelState.IsValid)
            {
                Shipment shipment = db.Shipments.SingleOrDefault(s => s.WaybillID == package.WaybillID);
                package.Shipment        = shipment;
                package.Fee             = PackageFee(package);
                db.Entry(package).State = EntityState.Modified;
                db.SaveChanges();


                shipment.ShipmentAmount = 0;
                foreach (Package p in shipment.Packages)
                {
                    shipment.ShipmentAmount += PackageFee(p);
                }
                db.Entry(shipment).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", new { WaybillId = package.WaybillID }));
            }
            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.Where(s => s.PackageTypeID == package.PackageTypeID), "PackageTypeSizeID", "TypeSize", package.PackageTypeSizeID);
            ViewBag.WaybillId         = package.WaybillID;
            return(View(package));
        }
コード例 #3
0
        public ActionResult Confirm(int id)
        {
            Shipment shipment = db.Shipments.Find(id);

            shipment.Status          = "Confirmed";
            Session["WaybillId"]     = id;
            db.Entry(shipment).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Create", "PickupInforations"));
        }
        public ActionResult Edit([Bind(Include = "PackageId,PackageTypeSize,Description,Value,CustomerWeight,ActualWeight,PackageCost,WaybillId")] Package package)
        {
            if (ModelState.IsValid)
            {
                decimal oldPackageCost = package.PackageCost;
                if ((float)Session["oldPackageWeight"] == 0)
                {
                    package.PackageCost = package.PackageCost * (decimal)package.ActualWeight / (decimal)package.CustomerWeight;
                }
                else
                {
                    float oldPackage = (float)Session["oldPackageWeight"];
                    package.PackageCost = package.PackageCost * (decimal)package.ActualWeight / (decimal)oldPackage;
                }
                if (Session["oldPackageWeight"] != null)
                {
                    Session.Remove("oldPackageWeight");
                }

                Shipment shipment = db.Shipments.Find(package.WaybillId);
                shipment.ShipmentCost = shipment.ShipmentCost - oldPackageCost + package.PackageCost;
                shipment.Status       = "Picked Up";
                shipment.ShippedDate  = DateTime.Now;

                //send email when package is picked up
                string rmail = shipment.RecipientEmail;
                string smail = shipment.ShippingAccount.Email;
                if (rmail == smail)
                {
                    if (shipment.NotifyRecipient || shipment.NotifySender)
                    {
                        SendInvoiceMail(rmail, shipment.WaybillId);
                    }
                }
                else
                {
                    if (shipment.NotifyRecipient)
                    {
                        SendInvoiceMail(rmail, shipment.WaybillId);
                    }
                    if (shipment.NotifySender)
                    {
                        SendInvoiceMail(smail, shipment.WaybillId);
                    }
                }

                db.Entry <Shipment>(shipment).State = EntityState.Modified;

                db.Entry(package).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", new { waybillId = package.WaybillId }));
            }
            ViewBag.WaybillId = new SelectList(db.Shipments, "WaybillId", "ReferenceNumber", package.WaybillId);
            return(RedirectToAction("Index", "Home"));
        }
コード例 #5
0
 public ActionResult TrackingSystemStatusEdit([Bind(Include = "WaybillID,RecipientName,DeliveredAt,Status,Destination,Origin,PickupDate")] Shipment shipment)
 {
     if (ModelState.IsValid)
     {
         db.Shipments.Attach(shipment);
         db.Entry(shipment).Property(x => x.RecipientName).IsModified = true;
         db.Entry(shipment).Property(x => x.DeliveredAt).IsModified   = true;
         db.Entry(shipment).Property(x => x.Status).IsModified        = true;
         db.Entry(shipment).Property(x => x.PickupDate).IsModified    = true;
         db.SaveChanges();
         return(RedirectToAction("TrackingSystemStatus"));
     }
     return(View(shipment));
 }
コード例 #6
0
        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"));
        }
コード例 #7
0
        public ActionResult CancellingShipment(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Shipment shipment = db.Shipments.Find(id);

            if (shipment == null)
            {
                return(HttpNotFound());
            }
            if (shipment.Status == "Cancelled")
            {
                ViewBag.CancelShipmentError = "Shipment already cancelled";
            }
            else if (!shipment.isConfirmed)
            {
                ViewBag.CancelShipmentError = "Shipment not confirmed yet.";
            }
            else if (db.TrackingSystemRecords.Where(s => s.WaybillId == id).Count() != 0)
            {
                ViewBag.CancelShipmentError = "Shipment already picked up.";
            }
            if (ViewBag.CancelShipmentError == null)
            {
                shipment.Status          = "Cancelled";
                db.Entry(shipment).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                Session["HandlingWaybillId"]  = id;
                ViewBag.DeliveryAddressEntity = GetAddressEntity(shipment.DeliveryAddress);
                ViewBag.PickupAddressEntity   = GetAddressEntity(shipment.PickupAddress);
                if (isPersonalShippingAccount(shipment.SenderId))
                {
                    ViewBag.SenderName = ((PersonalShippingAccount)shipment.Sender).FirstName + " " + ((PersonalShippingAccount)shipment.Sender).LastName;
                }
                else
                {
                    ViewBag.SenderName = ((BusinessShippingAccount)shipment.Sender).ContactPersonName;
                }
                return(View(shipment));
            }
        }
コード例 #8
0
        public ActionResult Create([Bind(Include = "PackageId,PackageTypeID,Description,Value,Weight,WaybillId")] Package package)
        {
            if (ModelState.IsValid)
            {
                package.WaybillId = int.Parse(Session["WaybillId"].ToString());

                db.Packages.Add(package);
                db.SaveChanges();
                Shipment shipment = db.Shipments.Find(package.WaybillId);
                shipment.NumberOfPackages++;
                db.Entry(shipment).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PackageTypeID = new SelectList(db.PackageTypes, "PackageTypeID", "Type", package.PackageTypeID);
            return(View(package));
        }
コード例 #9
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));
 }
コード例 #10
0
 public ActionResult Edit([Bind(Include = "PickupId,PickupTime,IsImmediatePickup")] Pickup pickup)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pickup).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pickup));
 }
コード例 #11
0
 public ActionResult Edit([Bind(Include = "TrackingSystemRecordId,WaybillId,DateTimeOfRecord,Activity,Location,Remarks,DeliveredTo,DeliveredAt,Status")] TrackingSystemRecord trackingSystemRecord)
 {
     if (ModelState.IsValid)
     {
         db.Entry(trackingSystemRecord).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(trackingSystemRecord));
 }
 public ActionResult Edit([Bind(Include = "DestinationID,City,CurrencyCode,ProvinceCode")] Destination destination)
 {
     if (ModelState.IsValid)
     {
         db.Entry(destination).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(destination));
 }
コード例 #13
0
 public ActionResult Edit([Bind(Include = "InvoiceId,WaybillId,ShipDate,RecipientName,Origin,Destination,ServiceType,InvoiceAmount")] Invoice invoice)
 {
     if (ModelState.IsValid)
     {
         db.Entry(invoice).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(invoice));
 }
 public ActionResult Edit([Bind(Include = "CurrencyCode,ExchangeRate")] Currency currency)
 {
     if (ModelState.IsValid)
     {
         db.Entry(currency).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(currency));
 }
コード例 #15
0
 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));
 }
コード例 #16
0
 public ActionResult Edit([Bind(Include = "ServiceTypeID,Type,CutoffTime,DeliveryTime")] ServiceType serviceType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(serviceType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(serviceType));
 }
コード例 #17
0
 public ActionResult Edit([Bind(Include = "WaybillId,ReerenceNumber,ServiceTypes,ShippedDate,DeliveredDate,RecipientName,NumberOfPackages,Origin,Destination,Status,ShippingAccountId")] Shipment shipment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(shipment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(shipment));
 }
コード例 #18
0
 public ActionResult Edit([Bind(Include = "PackageTypeID,Type,Description")] PackageType packageType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(packageType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(packageType));
 }
コード例 #19
0
 public ActionResult Edit([Bind(Include = "PackageTypeSizeID,Type,Description,PackageTypeID")] PackageTypeSize packageTypeSize)
 {
     if (ModelState.IsValid)
     {
         db.Entry(packageTypeSize).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PackageTypeID = new SelectList(db.PackageTypes, "PackageTypeID", "Type", packageTypeSize.PackageTypeID);
     return(View(packageTypeSize));
 }
コード例 #20
0
 public ActionResult Edit([Bind(Include = "WaybillId,Pickuptype,Pickuplocation,PickupDateTime")] PickupInforation pickupInforation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pickupInforation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.WaybillId = new SelectList(db.Shipments, "WaybillId", "ReferenceNumber", pickupInforation.WaybillId);
     return(View(pickupInforation));
 }
コード例 #21
0
 public ActionResult Edit([Bind(Include = "PaymentID,AuthorizationCode,WaybillID,PaymentAmount,CurrencyCode,UserName,PayerCharacter,PaymentDescription")] Invoice payment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(payment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.WaybillID = new SelectList(db.Shipments, "WaybillID", "ReferenceNumber", payment.WaybillID);
     return(View(payment));
 }
 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));
 }
 public ActionResult Edit(Shipment shipment, int WaybillId)
 {
     if (ModelState.IsValid)
     {
         //int? CurrentEditId = ViewBag.CurrentEditId;
         db.Entry(shipment).State = EntityState.Modified;
         db.SaveChanges();
         //return RedirectToAction("Index", "Home");
         return(RedirectToAction("InputShipmentDetails", new { waybillId = WaybillId }));
     }
     return(View(shipment));
 }
コード例 #24
0
 public ActionResult Edit([Bind(Include = "ServicePackageFeeID,Fee,MinimumFee,PackageTypeID,ServiceTypeID")] ServicePackageFee servicePackageFee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(servicePackageFee).State = EntityState.Modified;
         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));
 }
コード例 #25
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));
 }
コード例 #26
0
        public ActionResult Create([Bind(Include = "PackageId,PackageTypeSizeId,Description,ValueOfContent,ContentCurrency,EstimatedWeight")] Package package)
        {
            if (ModelState.IsValid && Session["HandlingWaybillId"] != null)
            {
                package.WaybillId = (int)Session["HandlingWaybillId"];
                db.Packages.Add(package);
                db.SaveChanges();
                Shipment relatedShipment = db.Shipments.Find(package.WaybillId);
                relatedShipment.NumberOfPackages = relatedShipment.Packages.Count();
                db.Entry(relatedShipment).State  = EntityState.Modified;
                db.SaveChanges();
                UpdateShipmentFee(relatedShipment.WaybillId, true);
                return(RedirectToAction("Index", "Packages"));
            }

            if (Session["HandlingWaybillId"] == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ViewBag.PackageTypeSizeId = PackageTypeSize.GetSelectList(package.PackageTypeSizeId);
            return(View(package));
        }
        public ActionResult Edit([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.Entry(pickUpLocation).State    = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(pickUpLocationViewModel));
        }
        public ActionResult ConfirmPickup(int?dummy)
        {
            PickupViewModel pickupViewModel = (PickupViewModel)Session["newPickupView"];
            Pickup          pickup          = (Pickup)Session["newPickup"];

            pickup.PickupId     = db.Pickups.Count() + 1;
            pickup.ProvinceCode = GetProvince(pickup.City);
            if (pickup.PickupDateTime == DateTime.MinValue)
            {
                pickup.PickupDateTime = new DateTime(1990, 1, 1);
            }

            foreach (var item in pickupViewModel.ShipmentCheckBoxes)
            {
                if (item.Checked == true)
                {
                    Shipment shipment = db.Shipments.Find(item.Value);
                    shipment.Pickup = pickup.PickupId;
                    shipment.Status = "Confirmed";
                    db.Entry <Shipment>(shipment).State = EntityState.Modified;
                }
            }

            db.Pickups.Add(pickup);
            db.SaveChanges();

            if (Session["newPickupView"] != null)
            {
                Session.Remove("newPickupView");
            }
            if (Session["newPickup"] != null)
            {
                Session.Remove("newPickup");
            }
            return(RedirectToAction("Index"));
        }
コード例 #29
0
        public ActionResult Edit([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.Entry(pickupLocation).State   = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.ShippingAccountID = new SelectList(db.ShippingAccounts, "ShippingAccountID", "UserName", pickupLocation.ShippingAccountID);
            return(View(pickupLocation));
        }
コード例 #30
0
        public ActionResult Edit([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.Entry(recipientAddress).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(recipientAddressViewModel));
        }