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));
        }
示例#2
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));
 }
示例#3
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));
 }
        public ActionResult SendTransportOrder(Enquiry enquiry, int service_provider_id, string subject, string message_body)
        {
            ServiceProvider serviceProvider = db.ServiceProviders.Find(service_provider_id);

            try
            {
                EmailTemplate.Send(serviceProvider.EmailAddress, "*****@*****.**", subject, EmailTemplate.FinalizeHtmlEmail(message_body), true);
                using (TranyrLogisticsDb context = new TranyrLogisticsDb())
                {
                    Enquiry currentEnquiry = context.Enquiries.Find(enquiry.ID);
                    currentEnquiry.PreferedServiceProviderID = service_provider_id;
                    currentEnquiry.TransportOrderSent        = true;
                    db.Entry(currentEnquiry).State           = EntityState.Modified;
                    db.SaveChanges();
                }
            }
            catch { }

            return(RedirectToAction("CustomerConfirmation", new { id = enquiry.ID }));
        }