public ActionResult Create(ShipmentDocument shipmentDocument)
        {
            if (Request.Files.Count > 0)
            {
                var    file                = Request.Files["FilePath"];
                var    fileName            = Path.GetFileName(file.FileName);
                string uploadDirectoryPath = Path.Combine(
                    AppDomain.CurrentDomain.BaseDirectory +
                    @"Uploads\ShipmentDocs\" + shipmentDocument.CustomerNumber + @"\"
                    );
                string savedFileName = Path.Combine(
                    uploadDirectoryPath,
                    DateTime.Now.Ticks + Path.GetExtension(fileName)
                    );
                if (!Directory.Exists(uploadDirectoryPath))
                {
                    Directory.CreateDirectory(uploadDirectoryPath);
                }
                file.SaveAs(savedFileName);
                shipmentDocument.ActualFileName = fileName;
                shipmentDocument.FilePathOnDisc = savedFileName;
            }

            shipmentDocument.CreateDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.ShipmentDocuments.Add(shipmentDocument);
                db.SaveChanges();

                return(RedirectToAction("Index", new { customer_number = shipmentDocument.CustomerNumber, shipment_id = shipmentDocument.ShipmentID }));
            }

            return(View(shipmentDocument));
        }
        public ActionResult Create(ShippingTerms shipmentTerms)
        {
            if (ModelState.IsValid)
            {
                db.ShippingTerms.Add(shipmentTerms);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(shipmentTerms));
        }
示例#3
0
        public ActionResult Create(Group group)
        {
            group.CreateDate = group.ModifiedDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.Groups.Add(group);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(group));
        }
示例#4
0
        public ActionResult Create(ServiceProvider serviceprovider)
        {
            serviceprovider.CreateDate = serviceprovider.ModifiedDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.ServiceProviders.Add(serviceprovider);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CountryID = new SelectList(db.Countries.OrderBy(x => x.Name), "ID", "Name");
            ViewBag.ServiceProviderGroupID = new SelectList(db.ServiceProviderGroups, "ID", "Name");

            return(View(serviceprovider));
        }
 public ActionResult Create(Customer customer, int enquiry_id = 0)
 {
     customer.CustomerNumber = CustomerModel.GenerateCustomerNumber(customer);
     customer.CreateDate     = customer.ModifiedDate = DateTime.Now;
     if (ModelState.IsValid)
     {
         db.Customers.Add(customer);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerGroupID = new SelectList(db.CustomerGroups, "ID", "Name", customer.CustomerGroupID);
     ViewBag.CountryID       = new SelectList(db.Countries.OrderBy(x => x.Name), "ID", "Name");
     return(View(customer));
 }
        public ActionResult Edit(Enquiry enquiry)
        {
            using (TranyrLogisticsDb db = new TranyrLogisticsDb())
            {
                var currentEnquiry = db.Enquiries.Find(enquiry.ID);
                if (enquiry is ExistingCustomerEnquiry)
                {
                    ((ExistingCustomerEnquiry)enquiry).CustomerID = ((ExistingCustomerEnquiry)currentEnquiry).CustomerID;
                }

                enquiry.VerificationSent   = currentEnquiry.VerificationSent;
                enquiry.QuotationRequested = currentEnquiry.QuotationRequested;
                enquiry.QuotationSent      = currentEnquiry.QuotationSent;
                enquiry.CreateDate         = currentEnquiry.CreateDate;
                enquiry.CreatedBy          = currentEnquiry.CreatedBy;
                enquiry.AssignedTo         = currentEnquiry.AssignedTo;
                enquiry.StatusIndex        = currentEnquiry.StatusIndex;
            }
            enquiry.ModifiedDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.Entry(enquiry).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OriginCountryID      = new SelectList(db.Countries.OrderBy(x => x.Name), "ID", "Name");
            ViewBag.DestinationCountryID = new SelectList(db.Countries.OrderBy(x => x.Name), "ID", "Name");

            return(View(enquiry));
        }
        public ActionResult Create(Shipment shipment)
        {
            shipment.ReferenceNumber      = ShipmentModel.GenerateReferenceNumber(shipment);
            shipment.ActualCollectionTime = shipment.PlannedCollectionTime;
            shipment.ActualTimeOfArrival  = shipment.PlannedETA;
            shipment.CreateDate           = shipment.ModifiedDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                shipment.CreatedBy = User.Identity.Name;

                if (shipment.ReferralEnquiryID > 0)
                {
                    var enquiry = db.Enquiries.Find(shipment.ReferralEnquiryID);
                    if (enquiry == null)
                    {
                        return(RedirectToAction("Error"));
                    }
                    enquiry.Status          = Enquiry.State.CLOSED;
                    db.Entry(enquiry).State = EntityState.Modified;
                }

                db.Shipments.Add(shipment);
                db.SaveChanges();

                if (shipment.InsuranceRequired)
                {
                    shipment.Customer = db.Customers.Find(shipment.CustomerID);
                    EmailTemplate.Send(
                        "*****@*****.**",
                        "*****@*****.**",
                        "Shipment Insurance Request",
                        EmailTemplate.PerpareInsuranceRequestEmail(shipment, @"~\views\EmailTemplate\InsuranceRequestEmail.html.cshtml"),
                        true
                        );
                }
                return(RedirectToAction("Index"));
            }
            return(this.Create(shipment.CustomerID));
        }
示例#8
0
 public ActionResult Edit(Group group)
 {
     using (TranyrLogisticsDb db = new TranyrLogisticsDb())
     {
         var currentGroup = db.Groups.Find(group.ID);
         group.CreateDate = currentGroup.CreateDate;
     }
     group.ModifiedDate = DateTime.Now;
     if (ModelState.IsValid)
     {
         db.Entry(group).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(group));
 }
        public ActionResult CreateExistingCustomerEnquiry(Enquiry enquiry)
        {
            enquiry.OriginCountry      = db.Countries.Find(enquiry.OriginCountryID);
            enquiry.DestinationCountry = db.Countries.Find(enquiry.DestinationCountryID);
            enquiry.CreateDate         = enquiry.ModifiedDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                try
                {
                    var customer = db.Customers.FirstOrDefault(x => x.CustomerNumber == ((ExistingCustomerEnquiry)enquiry).CustomerNumber);
                    if (customer == null)
                    {
                        return(RedirectToAction("NotFound"));
                    }

                    ((ExistingCustomerEnquiry)enquiry).CustomerID = customer.ID;
                    ((ExistingCustomerEnquiry)enquiry).Customer   = customer;

                    EmailTemplate.Send(
                        ((ExistingCustomerEnquiry)enquiry).Customer.EmailAddress,
                        "*****@*****.**",
                        "Enquiry Verification",
                        EmailTemplate.PrepareVerificationEmail(enquiry, @"~\views\EmailTemplate\EnquiryVerificationEmail.html.cshtml"),
                        true
                        );
                    enquiry.VerificationSent = true;
                }
                catch { }

                enquiry.CreatedBy = User.Identity.Name;
                enquiry.Status    = Enquiry.State.OPEN;

                db.Enquiries.Add(enquiry);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.OriginCountryID      = new SelectList(db.Countries.OrderBy(x => x.Name), "ID", "Name");
            ViewBag.DestinationCountryID = new SelectList(db.Countries.OrderBy(x => x.Name), "ID", "Name");

            return(View(enquiry));
        }
示例#10
0
        public ActionResult Edit(ServiceProvider serviceProvider)
        {
            using (TranyrLogisticsDb db = new TranyrLogisticsDb())
            {
                ServiceProvider currentServiceprovider = db.ServiceProviders.Find(serviceProvider.ID);
                serviceProvider.CreateDate = currentServiceprovider.CreateDate;
            }
            serviceProvider.ModifiedDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.Entry(serviceProvider).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CountryID = new SelectList(db.Countries.OrderBy(x => x.Name), "ID", "Name", serviceProvider.CountryID);
            ViewBag.ServiceProviderGroupID = new SelectList(db.ServiceProviderGroups, "ID", "Name", serviceProvider.ServiceProviderGroupID);

            return(View(serviceProvider));
        }
 public ActionResult Edit(Shipment shipment)
 {
     using (TranyrLogisticsDb db = new TranyrLogisticsDb())
     {
         Shipment currentShipment = db.Shipments.Find(shipment.ID);
         shipment.CustomerID      = currentShipment.CustomerID;
         shipment.ReferenceNumber = currentShipment.ReferenceNumber;
         shipment.CreateDate      = currentShipment.CreateDate;
         shipment.CreatedBy       = currentShipment.CreatedBy;
     }
     shipment.ModifiedDate = DateTime.Now;
     if (ModelState.IsValid)
     {
         db.Entry(shipment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(this.Edit(shipment.ID));
 }