Ejemplo n.º 1
0
        public IHttpActionResult SendPickUpEmail(SequencingWrapperModel model)
        {
            SendEmail email = new SendEmail();
            SequencingWrapperModel templateData = new SequencingWrapperModel();

            templateData.PickUp = model.PickUp;
            //
            email.SendPickUp(templateData);

            return(Ok());
        }
Ejemplo n.º 2
0
        public ActionResult Order(int?oligonucleotideNum)
        {
            var model = new SequencingWrapperModel();

            ViewBag.Message = "Your contact page.";
            Createviewbags();
            if (oligonucleotideNum != null)
            {
                ViewBag.MakeCount = oligonucleotideNum;
            }
            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult SubmitOrder(SequencingWrapperModel model, FormCollection form)
        {
            var num = form["oNum"];

            if (ModelState.IsValid)
            {
                var myList = CreateOrder(model);

                ///Generate(model);
                //   var productList = new List<object> { myList.ToList() };
                //   Createviewbags();

                return(RedirectToAction("Thankyou"));
            }
            else
            {
                Createviewbags();
                return(View("Order", model));
            }
        }
Ejemplo n.º 4
0
        public void SendPickUp(SequencingWrapperModel model)
        {
            SequencingWrapperModel m = new SequencingWrapperModel();

            m.PickUp = model.PickUp;
            var ship = "<table><td>";

            ship += "<table width='100' style='float:left' cellpadding='0 cellspacing='0' border='0 align='center'>";
            ship += "<thead>";
            ship += "<tr>";
            ship += "<th ><h1  style='color:blue;text-decoration: underline;'>Pick Up Information</h1</th>";
            ship += "</tr>";
            ship += "</thead>";
            ship += "<tr>";
            ship += "<td valign='top'>";
            ship += "<label for='fullName'>Full Name</label>";
            ship += "</td>";
            ship += "<td valign='top'>";
            ship += m.PickUp.FirstName;
            ship += "</td>";
            ship += "</tr>";
            ship += "<tr>";
            ship += "<td valign='top'>";
            ship += "<label for='fullName'>Last Name</label>";
            ship += "</td>";
            ship += "<td valign='top'>";
            ship += m.PickUp.LastName;
            ship += "</td>";
            ship += "</tr>";
            ship += "<tr>";
            ship += "<td valign='top'>";
            ship += "<label for='fullName'>Institution</label>";
            ship += "</td>";
            ship += "<td valign='top'>";
            ship += m.PickUp.Institution;
            ship += "</td>";
            ship += "</tr>";
            ship += "<tr>";
            ship += "<td valign='top'>";
            ship += "<label for='fullName'>Message</label>";
            ship += "</td>";
            ship += "<td valign='top'>";
            ship += m.PickUp.Message;
            ship += "</td>";
            ship += "</tr>";
            ship += "<tr>";
            ship += "<td valign='top'>";
            ship += "<label for='shippingEmail'>Room</label>";
            ship += "</td>";
            ship += "<td valign='top'>";
            ship += m.PickUp.Room;
            ship += "</td>";
            ship += "</tr>";
            ship += "<tr>";
            ship += "<td valign='top'>";
            ship += "<label for='shippingEmail'>Notes</label>";
            ship += "</td>";
            ship += "<td valign='top'>";
            ship += m.PickUp.Notes;
            ship += "</td>";
            ship += "</tr>";
            ship += "<tr>";
            ship += "<td valign='top'>";
            ship += "<label for='shippingEmail'>Email</label>";
            ship += "</td>";
            ship += "<td valign='top'>";
            ship += m.PickUp.Email;
            ship += "</td>";
            ship += "</tr>";
            ship += "</table>";

            ship += "</table> </body> </html>";

            var template = StaticValues.HtmlHeaderText() + ship;

            CreateEmailForUser(m.PickUp.Email, "*****@*****.**", template);
        }
Ejemplo n.º 5
0
        //public string CreateEmailForJason(string toSender, string fromSender, string body) {
        //    try {


        //        //Create the msg object to be sent
        //        MailMessage msg = new MailMessage();
        //        //Add your email address to the recipients
        //        msg.To.Add("*****@*****.**");
        //        //  msg.To.Add("*****@*****.**");
        //        //Configure the address we are sending the mail from
        //        MailAddress address = new MailAddress("*****@*****.**");
        //      //  MailAddress addressBCC = new MailAddress("*****@*****.**");
        //        msg.From = address;
        //    //    msg.Bcc.Add(addressBCC);
        //        msg.Subject = "Order form";
        //        msg.IsBodyHtml = true;
        //        msg.Body = body;
        //        byte[] a = GetData(body);
        //        System.IO.MemoryStream m = new System.IO.MemoryStream(a);
        //        Attachment word = new Attachment(m, "Client-"+fromSender+".doc");
        //        msg.Attachments.Add(word);

        //        ////Configure an SmtpClient to send the mail.
        //        SmtpClient smptc = new SmtpClient(); // Here SMTP Client object is created
        //        //   smptc.Host = "smtpout.asia.secureserver.net";// here SMTP interface Address is passed
        //        smptc.Port = 25;// Use port No 25
        //        smptc.UseDefaultCredentials = false;
        //        smptc.EnableSsl = false;
        //        smptc.DeliveryMethod = SmtpDeliveryMethod.Network;
        //        NetworkCredential credentials = new NetworkCredential("*****@*****.**", "Travel2014");
        //        smptc.Credentials = credentials;
        //        smptc.Send(msg);

        //        ////Setup credentials to login to our sender email address ("UserName", "Password")
        //        //NetworkCredential credentials = new NetworkCredential("*****@*****.**", "Oscar@2015");
        //        //client.UseDefaultCredentials = true;
        //        //client.Credentials = credentials;

        //        ////Send the msg
        //        //client.Send(msg);
        //        //var client = new SmtpClient("smtp.gmail.com", 587) {
        //        //    Credentials = new NetworkCredential("*****@*****.**", "Oscar@2015"),
        //        //    EnableSsl = true
        //        //};

        //        //client.Send("*****@*****.**", "*****@*****.**", "test", "testbody");

        //        return "Ok";
        //    } catch (Exception ex) {
        //      return   ex.InnerException.ToString();
        //    }
        //}
        public string SetUpSequence(SequencingWrapperModel model)
        {
            SequencingWrapperModel m = new SequencingWrapperModel();

            m.Billing             = model.Billing;
            m.PickUp              = model.PickUp;
            m.sequencingModel     = model.sequencingModel;
            m.customPrimers       = model.customPrimers;
            m.DataDeliveryOptions = model.DataDeliveryOptions;


            var dnaForm = "";

            //headers<img src=\"cid:image1\">
            //  var ship = "<table><td align='center' style='padding: 40px 0 30 px 0;'><img src='http://youneedafavor.com/images/logo.png'>";
            var ship = "<table><td>";

            ship += "<h1>" + model.Billing.FullName + " " + "here is your Sequencing order</h1></td></table>";

            if (model.IsShipping)
            {
                ship += "<table width='100' style='float:left' cellpadding='0' cellspacing='0' border='0' align='center'>";
                ship += "<thead>";
                ship += "<tr>";
                ship += "<th ><h1 style='color:blue;text-decoration: underline;'>Pick Up Information</h1></th>";
                ship += "</tr>";
                ship += "</thead>";
                ship += "<tr>";
                ship += "<td valign='top'>";
                ship += "<label for='fullName'>Full Name</label>";
                ship += "</td>";
                ship += "<td valign='top'>";
                ship += m.PickUp.FullName;
                ship += "</td>";
                ship += "</tr>";
                ship += "<tr>";
                ship += "<td valign='top'>";
                ship += "<label for='fullName'>Institution</label>";
                ship += "</td>";
                ship += "<td valign='top'>";
                ship += m.PickUp.Institution;
                ship += "</td>";
                ship += "</tr>";
                ship += "<tr>";
                ship += "<td valign='top'>";
                ship += "<label for='fullName'>Shipping Address</label>";
                ship += "</td>";
                ship += "<td valign='top'>";
                ship += m.PickUp.ShippingAddress;
                ship += "</td>";
                ship += "</tr>";
                ship += "<tr>";
                ship += "<td valign='top'>";
                ship += "<label for='fullName'>Shipping Phone</label>";
                ship += "</td>";
                ship += "<td valign='top'>";
                ship += m.PickUp.Phone;
                ship += "</td>";
                ship += "</tr>";
                ship += "<tr>";
                ship += "<td valign='top'>";
                ship += "<label for='shippingEmail'>Shipping Email</label>";
                ship += "</td>";
                ship += "<td valign='top'>";
                ship += m.PickUp.Email;
                ship += "</td>";
                ship += "</tr>";
                ship += "</table>";
            }
            //Billing


            var bill = "<table width='100' style=cellpadding='0' cellspacing='0' border='0 align='center'>";

            bill += "<thead>";
            bill += "<tr>";
            bill += "<th ><h1 style='color:blue;text-decoration: underline;'>Billing Information</h1></th>";
            bill += "</tr>";
            bill += "</thead>";
            bill += "<tr>";
            bill += "<td valign='top'>";
            bill += "<label for='first_name'>Quote</label>";
            bill += "</td>";
            bill += "<td valign='top'>";
            bill += m.Billing.Quotenumber;
            bill += "</td>";
            bill += "</tr>";
            // Full Name
            bill += "<tr>";
            bill += "<td valign='top'>";
            bill += "<label for='first_name'>Full Name</label>";
            bill += "</td>";
            bill += "<td valign='top'>";
            bill += m.Billing.FullName;
            bill += "</td>";
            bill += "</tr>";
            //Institution
            bill += "<tr>";
            bill += "<td valign='top'>";
            bill += "<label for='first_name'>Institution</label>";
            bill += "</td>";
            bill += "<td valign='top'>";
            bill += m.Billing.Institution;
            bill += "</td>";
            bill += "</tr>";
            //Billing Address
            bill += "<tr>";
            bill += "<td valign='top'>";
            bill += "<label for='first_name'>Billing Address</label>";
            bill += "</td>";
            bill += "<td valign='top'>";
            bill += m.Billing.BillingAddress;
            bill += "</td>";
            bill += "</tr>";
            //Billing Phone
            bill += "<tr>";
            bill += "<td valign='top'>";
            bill += "<label for='first_name'>Biling Phone</label>";
            bill += "</td>";
            bill += "<td valign='top'>";
            bill += m.Billing.Phone;
            bill += "</td>";
            bill += "</tr>";
            //Billing Email
            bill += "<tr>";
            bill += "<td valign='top'>";
            bill += "<label for='first_name'>Billing Email</label>";
            bill += "</td>";
            bill += "<td valign='top'>";
            bill += m.Billing.Email;
            bill += "</td>";
            bill += "</tr>";
            bill += "<tr>";
            bill += "<td valign='top'>";
            bill += "<label for='first_name'>Notes</label>";
            bill += "</td>";
            bill += "<td valign='top'>";
            bill += m.Billing.Notes;
            bill += "</td>";
            bill += "</tr>";
            bill += "</table>";
            var olForm = "<h1 style='padding-top:400px; color:blue;text-decoration: underline;page-break-before:always;'>Sequencing</h1>";;

            olForm += "<table width='100%' style='float:left' cellpadding='0' cellspacing='0'  align='center' border='1'>";

            //olForm += "<thead>";
            //olForm += "<tr>";
            //olForm += "<th>Sequencing</th>";
            //olForm += "</tr>";
            //olForm += "</thead>";
            olForm += "<tr  style='width:100%'>";
            olForm += "<td class='boldCell'>Sample Name</td>";
            olForm += "<td class='boldCell'>Sample Conc</td>";
            olForm += "<td class='boldCell'>Vector Name</td>";
            olForm += "<td class='boldCell'>Length</td>";
            olForm += "<td class='boldCell'>Primer Name</td>";
            olForm += "<td class='boldCell'>Primer Conc</td>";
            olForm += "<td class='boldCell'>GMP3</td>";
            olForm += "<td class='boldCell'>SeqID</td>";
            olForm += "<td class='boldCell'>Template OD</td>";
            olForm += "<td class='boldCell'>Primer OD</td>";
            olForm += "<td class='boldCell'>Repeat</td>";

            // more cells here as needed
            olForm += "</tr>";

            for (int i = 0; i < m.sequencingModel.Count(); i++)
            {
                olForm += "<tr>";
                olForm += "<td class='boldCell'>" + m.sequencingModel[i].SampleName + "</td>";
                olForm += "<td class='boldCell'>" + m.sequencingModel[i].SampleCon + "</td>";
                olForm += "<td class='boldCell'>" + m.sequencingModel[i].VectorName + "</td>";
                olForm += "<td class='boldCell'>" + m.sequencingModel[i].Length + "</td>";
                olForm += "<td class='boldCell'>" + m.sequencingModel[i].PrimerName + "</td>";
                olForm += "<td class='boldCell'>" + m.sequencingModel[i].PrimerConc + "</td>";
                olForm += "<td class='boldCell'>" + m.sequencingModel[i].GmpValue + "</td>";
                olForm += "<td class='boldCell'> </td>";
                olForm += "<td class='boldCell'> </td>";
                olForm += "<td class='boldCell'> </td>";
                olForm += "<td class='boldCell'> </td>";
                // more cells here as needed
                olForm += "</tr>";
            }
            olForm += "</table>";
            if (model.IsPrimer)
            {
                dnaForm  = "<h1>Custom Primers</h1>";;
                dnaForm += "<table style='width:100%'  border='1'>";

                dnaForm += "<tr  style='width:100%'>";
                //   dnaForm += "<td class='boldCell'>Gmp</td>";
                dnaForm += "<td class='boldCell'>Primer Named</td>";
                //  dnaForm += "<td class='boldCell'>Scale Value</td>";
                dnaForm += "<td class='boldCell'>Sequence</td>";
                // more cells here as needed
                dnaForm += "</tr>";


                for (int i = 0; i < m.customPrimers.Count(); i++)
                {
                    dnaForm += "<tr>";
                    // dnaForm += "<td class='boldCell'>" + m.customPrimers[i].GmpValue + "</td>";
                    dnaForm += "<td class='boldCell'>" + m.customPrimers[i].PrimerName + "</td>";
                    //     dnaForm += "<td class='boldCell'>" + m.customPrimers[i].ScaleValue + "</td>";
                    dnaForm += "<td class='boldCell'>" + m.customPrimers[i].Sequence + "</td>";
                    // more cells here as needed
                    dnaForm += "</tr>";
                }
                dnaForm += "</table>";
            }

            var deliveryOptions = "<h1>Delivery Options</h1>";;

            deliveryOptions += "<table style='width:100%' class='panel-title' border='1'>";

            deliveryOptions += "<tr  style='width:100%'>";
            deliveryOptions += "<td class='boldCell'>" + m.DataDeliveryOptions.Name + " </td>";
            // more cells here as needed
            deliveryOptions += "</tr>";



            //deliveryOptions += "<tr>";
            //deliveryOptions += "<td class='boldCell'>" + m.DataDeliveryOptions.Value + "</td>";
            //// more cells here as needed
            //deliveryOptions += "</tr>";

            deliveryOptions += "</table> </body> </html>";

            var template = StaticValues.HtmlHeaderText() + ship + bill + olForm + dnaForm + deliveryOptions;

            CreateEmailForUser(m.Billing.Email, "*****@*****.**", template);
            CreateEmailForJason(m.Billing.Email, "*****@*****.**", template);
            CreateEmailForAnders(m.Billing.Email, "*****@*****.**", template);
            return(olForm);
        }
Ejemplo n.º 6
0
        public IHttpActionResult Post(SequencingWrapperModel model)
        {
            //Insert into database
            SequencingWrapperModel templateData = new SequencingWrapperModel();

            List <SequencingModel> getList          = new List <SequencingModel>();
            List <CustomPrimers>   getCustomPrimers = new List <CustomPrimers>();
            Guid g = Guid.NewGuid();

            try {
                Billing bill = new Billing();
                //  bill.Date = DateTime.Now;
                bill.FullName        = model.Billing.FullName;
                bill.Quotenumber     = model.Billing.Quotenumber;
                bill.Institution     = model.Billing.Institution;
                bill.BillingAddress  = model.Billing.BillingAddress;
                bill.Phone           = model.Billing.Phone;
                bill.Email           = model.Billing.Email;
                bill.Notes           = model.Billing.Notes;
                bill.UserId          = g;
                templateData.Billing = bill;

                //   db.Entry(bill).State = EntityState.Added;
                // db.Billing.Add(bill);

                if (model.IsShipping)
                {
                    //Pickup

                    PickUp ship = new PickUp();
                    ship.PickUpDate      = model.PickUp.PickUpDate;
                    ship.FullName        = model.PickUp.FullName;
                    ship.Institution     = model.PickUp.Institution;
                    ship.ShippingAddress = model.PickUp.ShippingAddress;
                    ship.Phone           = model.PickUp.Phone;
                    ship.Email           = model.PickUp.Email;

                    ship.UserId = g;
                    //db.PickUp.Add(ship);
                    //db.Entry(ship).State = EntityState.Added;
                    templateData.PickUp = ship;
                }

                //DNA
                SequencingModel ol;
                for (int i = 0; i < model.sequencingModel.Count(); i++)
                {
                    ol            = new SequencingModel();
                    ol.SampleName = model.sequencingModel[i].SampleName;
                    ol.SampleCon  = model.sequencingModel[i].SampleCon;
                    ol.VectorName = model.sequencingModel[i].VectorName;
                    ol.Length     = model.sequencingModel[i].Length;
                    ol.PrimerName = model.sequencingModel[i].PrimerName;
                    ol.PrimerConc = model.sequencingModel[i].PrimerConc;
                    ol.GmpValue   = model.sequencingModel[i].GmpValue;
                    ol.UserId     = g;
                    //Ties into the other id's
                    //db.SequencingModel.Add(ol);
                    getList.Add(ol);
                    //db.Entry(ol).State = EntityState.Added;
                }


                //DNA
                if (model.IsPrimer)
                {
                    CustomPrimers cp;
                    for (int i = 0; i < model.customPrimers.Count(); i++)
                    {
                        cp            = new CustomPrimers();
                        cp.GmpValue   = model.customPrimers[i].GmpValue;
                        cp.PrimerName = model.customPrimers[i].PrimerName;
                        cp.ScaleValue = model.customPrimers[i].ScaleValue;
                        cp.Sequence   = model.customPrimers[i].Sequence;
                        cp.UserId     = g;
                        //Ties into the other id's
                        //   db.CustomPrimers.Add(cp);
                        // db.Entry(cp).State = EntityState.Added;
                        getCustomPrimers.Add(cp);
                    }
                }


                DataDeliveryOptions ddd = new DataDeliveryOptions();
                ddd.Name  = model.DataDeliveryOptions.Name;
                ddd.Value = model.DataDeliveryOptions.Value;
                //     db.dataDeliveryOptions.Add(ddd);
                templateData.DataDeliveryOptions = ddd;
                //   db.Entry(ddd).State = EntityState.Added;

                //Create email template!
                SendEmail email = new SendEmail();
                templateData.sequencingModel = getList;
                templateData.customPrimers   = getCustomPrimers;
                templateData.IsPrimer        = model.IsPrimer;
                templateData.IsShipping      = model.IsShipping;
                //
                email.SetUpSequence(templateData);
                // ParseTemplate(ob);
                //     db.SaveChanges();
                return(Ok());
                // return templateData;
            } catch (DbEntityValidationException ex) {
                // Retrieve the error messages as a list of strings.
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join("; ", errorMessages);
                // Combine the original exception message with the new one.
                var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
                // Throw a new DbEntityValidationException with the improved exception message.
                throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
            }
        }
Ejemplo n.º 7
0
        private SequencingWrapperModel CreateOrder(SequencingWrapperModel model)
        {
            return(null);
            //SequencingWrapperModel templateData = new SequencingWrapperModel();
            //List<SequencingModel> getList = new List<SequencingModel>();
            //Guid g = Guid.NewGuid();
            //try {

            //    Billing bill = new Billing();
            //    //  bill.Date = DateTime.Now;
            //    bill.FullName = model.billing.FullName;
            //    bill.Quotenumber = model.billing.Quotenumber;
            //    bill.Institution = model.billing.Institution;
            //    bill.BillingAddress = model.billing.BillingAddress;
            //    bill.Phone = model.billing.Phone;
            //    bill.Email = model.billing.Email;
            //    bill.UserId = g;
            //    templateData.billing = bill;

            //    db.Entry(bill).State = EntityState.Added;
            //    db.Billing.Add(bill);


            //    //Shipping
            //    Shipping ship = new Shipping();
            //    ship.Date = model.shipping.Date;
            //    ship.FullName = model.shipping.FullName;
            //    ship.Institution = model.shipping.Institution;
            //    ship.ShippingAddress = model.shipping.ShippingAddress;
            //    ship.Phone = model.shipping.Phone;
            //    ship.Email = model.shipping.Email;
            //    ship.UserId = g;
            //    db.Shipping.Add(ship);
            //    db.Entry(ship).State = EntityState.Added;
            //    templateData.shipping = ship;

            //    //Oligosequence
            //    SequencingModel ol = new SequencingModel();
            //    for (int i = 0; i < model.sequencingModel.Count(); i++) {
            //        var final = Core.StaticValues.FinalDelivery.SingleOrDefault(x => x.Value == Convert.ToString(model.sequencingModel[i].SampleName));
            //        ol.SampleName = model.sequencingModel[i].SampleName;
            //        ol.SampleCon = model.sequencingModel[i].SampleCon;
            //        ol.VectorName = model.sequencingModel[i].VectorName;
            //        ol.Length = model.sequencingModel[i].Length;
            //        ol.PrimerName = model.sequencingModel[i].PrimerName;
            //        ol.PrimerConc = model.sequencingModel[i].PrimerConc;
            //        ol.GMP3 = model.sequencingModel[i].GMP3;
            //        ol.UserId = g;
            //        //Ties into the other id's
            //        db.SequencingModel.Add(ol);
            //        getList.Add(ol);
            //    }
            //    db.Entry(ol).State = EntityState.Added;


            //    DataDeliveryOptions ddd = new DataDeliveryOptions();
            //    ddd.TextData = model.dataDeliveryOptions.TextData;
            //    ddd.ChromatogramTrace = model.dataDeliveryOptions.ChromatogramTrace;
            //    ddd.TextAndChromatogramTrace = model.dataDeliveryOptions.TextDataAndChromatogramTrace;
            //    ddd.TextDataAndChromatogramTrace = model.dataDeliveryOptions.TextDataAndChromatogramTrace;
            //    ddd.UserId = g;
            //    db.dataDeliveryOptions.Add(ddd);
            //    db.Entry(ddd).State = EntityState.Added;

            //    //Create email template!
            //    SendEmail email = new SendEmail();
            //    templateData.sequencingModel = getList;
            //    email.SetUpSequence(templateData);
            //    // ParseTemplate(ob);
            //    db.SaveChanges();
            //    return templateData;
            //} catch (DbEntityValidationException ex) {
            //    // Retrieve the error messages as a list of strings.
            //    var errorMessages = ex.EntityValidationErrors
            //        .SelectMany(x => x.ValidationErrors)
            //        .Select(x => x.ErrorMessage);

            //    // Join the list to a single string.
            //    var fullErrorMessage = string.Join("; ", errorMessages);
            //    // Combine the original exception message with the new one.
            //    var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
            //    // Throw a new DbEntityValidationException with the improved exception message.
            //    throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
            //}
        }