public IActionResult NewHobby() { if (HttpContext.Session.GetInt32("UserID") == null) { return(View("Index")); } else { WrapperModel ViewModel = new WrapperModel(); ViewModel.newUser = dbContext.Users.FirstOrDefault(u => u.UserID == HttpContext.Session.GetInt32("UserID")); return(View("NewHobby")); } }
public IActionResult CreateProduct(WrapperModel product) { if (ModelState.IsValid) { dbContext.Products.Add(product.NewProduct); dbContext.SaveChanges(); return(RedirectToAction("Product")); } else { return(View("Product")); } }
public IActionResult CreateCategory(WrapperModel category) { if (ModelState.IsValid) { dbContext.Categories.Add(category.NewCategory); dbContext.SaveChanges(); return(RedirectToAction("Category")); } else { return(View("Category")); } }
public IActionResult DisplayIdea(int id) { if (HttpContext.Session.GetString("userName") == null) { return(RedirectToAction("Index")); } else { WrapperModel viewMod = new WrapperModel(); viewMod.NewIdea = dbContext.Ideas.Include(i => i.Creator).Include(i => i.IdeaLikes).ThenInclude(u => u.Alias).FirstOrDefault(i => i.IdeaId == id); return(View(viewMod)); } }
public IActionResult EditHobby(int HobbyID) { if (HttpContext.Session.GetInt32("UserID") == null) { return(View("Index")); } else { WrapperModel ViewModel = new WrapperModel(); ViewModel.newHobby = dbContext.Hobbies.FirstOrDefault(w => w.HobbyID == HobbyID); return(View("EditHobby", ViewModel)); } }
public IActionResult JoinActivity(int UserId, int ThingId) { Association newAssociation = new Association(); newAssociation.PersonId = UserId; newAssociation.ThingId = ThingId; dbContext.Add(newAssociation); dbContext.SaveChanges(); WrapperModel newModel = new WrapperModel(); newModel.LoggedInUser = dbContext.users.SingleOrDefault(u => u.UserId == UserId); newModel.AllOccasions = dbContext.occasions.OrderBy(o => o.Date).Include(o => o.Attendants).ThenInclude(a => a.Person).ToList(); return(RedirectToAction("Dashboard", newModel)); }
public IActionResult Ideas() { if (HttpContext.Session.GetString("userName") == null) { return(RedirectToAction("Index")); } else { WrapperModel viewMod = new WrapperModel(); viewMod.User = dbContext.Users.FirstOrDefault(u => u.UserId == (int)HttpContext.Session.GetInt32("userId")); viewMod.AllIdeas = dbContext.Ideas.Include(u => u.Creator).Include(c => c.IdeaLikes).OrderByDescending(c => c.IdeaLikes.Count).ToList(); return(View(viewMod)); } }
public IActionResult Wall() { if (HttpContext.Session.GetString("userName") == null) { return(RedirectToAction("Index")); } else { WrapperModel viewMod = new WrapperModel(); viewMod.AllMessages = dbContext.Messages.Include(u => u.Creator).Include(c => c.MessageComments).ThenInclude(m => m.Creator).OrderByDescending(c => c.Created_at).ToList(); ViewBag.Username = HttpContext.Session.GetString("userName"); ViewBag.UserId = (int)HttpContext.Session.GetInt32("userId"); return(View(viewMod)); } }
public IActionResult ViewWedding(int weddingID) { if (HttpContext.Session.GetInt32("UserID") == null) { return(View("Index")); } else { WrapperModel ViewModel = new WrapperModel(); ViewModel.newWedding = dbContext.Weddings .Include(u => u.WeddingGuest) .ThenInclude(u => u.User) .FirstOrDefault(w => w.WeddingID == weddingID); return(View("ViewWedding", ViewModel)); } }
public IActionResult DeleteWedding(int WeddingID) { if (HttpContext.Session.GetInt32("UserID") == null) { return(View("Index")); } else { WrapperModel ViewModel = new WrapperModel(); ViewModel.newUser = dbContext.Users.FirstOrDefault(u => u.UserID == HttpContext.Session.GetInt32("UserID")); Wedding deleteWedding = dbContext.Weddings.SingleOrDefault(d => d.WeddingID == WeddingID); dbContext.Weddings.Remove(deleteWedding); dbContext.SaveChanges(); return(RedirectToAction("Dashboard", ViewModel)); } }
private void DetectBt_Click(object sender, RoutedEventArgs e) { if (ImagePath != null) { WrapperModel model = WrapperModel.Instance; model.FilePath = ImagePath; List <DetectedItemInfo> items = new List <DetectedItemInfo>(); items = model.Detect(); SetDetectedItemsToBindableItems(items); } else { MessageBoxResult result = MessageBox.Show("Please select an image.", "Image not found.", MessageBoxButton.OK, MessageBoxImage.Information); } }
public IActionResult NewProject(Project newProject) { int CurrentTeacher = (int)InSession; if (ModelState.IsValid) { newProject.CreatorId = CurrentTeacher; dbContext.projects.Add(newProject); dbContext.SaveChanges(); return(RedirectToAction("TeachDashboard", new{ TeacherId = CurrentTeacher })); } WrapperModel newModel = new WrapperModel(); newModel.LoggedInUser = dbContext.users.SingleOrDefault(u => u.UserId == CurrentTeacher); newModel.AllProjects = dbContext.projects.ToList(); return(View("TeachDashboard", new{ TeacherId = CurrentTeacher })); }
public IActionResult ViewHobby(int HobbyID) { if (HttpContext.Session.GetInt32("UserID") == null) { return(View("Index")); } else { WrapperModel ViewModel = new WrapperModel(); ViewModel.newUser = dbContext.Users.FirstOrDefault(u => u.UserID == HttpContext.Session.GetInt32("UserID")); ViewModel.newHobby = dbContext.Hobbies .Include(u => u.Creator) .Include(u => u.Enthusiast) .ThenInclude(u => u.User) .FirstOrDefault(w => w.HobbyID == HobbyID); return(View("ViewHobby", ViewModel)); } }
public IActionResult MakeNewDish(WrapperModel WrappedDish) { if (dbContext.Chefs.FirstOrDefault(chef => chef.ChefId == WrappedDish.OneDish.ChefId) == null) { ModelState.AddModelError("OneDish.ChefId", "There is no chef that goes by that ID"); } if (ModelState.IsValid) { dbContext.Add(WrappedDish.OneDish); dbContext.SaveChanges(); return(RedirectToAction("Dishes")); } else { WrappedDish.AllChefs = dbContext.Chefs.ToList(); return(View("NewDish", WrappedDish)); } }
public IActionResult Info(int OccasionId) { if (HttpContext.Session.GetInt32("UserId") == null) { return(RedirectToAction("Index")); } int UserID = HttpContext.Session.GetInt32("UserId").Value; Occasion thisOcc = dbContext.occasions.Include(o => o.Attendants).ThenInclude(a => a.Person).SingleOrDefault(to => to.OccasionId == OccasionId); thisOcc.CoordinatorUser = dbContext.users.SingleOrDefault(u => u.UserId == thisOcc.CoordinatorId); WrapperModel newModel = new WrapperModel(); newModel.LoggedInUser = dbContext.users.SingleOrDefault(u => u.UserId == UserID); newModel.ThisOccasion = thisOcc; System.Console.WriteLine("***********************"); System.Console.WriteLine(newModel.ThisOccasion.CoordinatorUser.UserId); return(View(newModel)); }
static void Main(string[] args) { try { Logger.Debug("Wrapper strating"); if (args == null) { Logger.Warn("No arguments were passed. Algorithm must accept 2 arguments."); } Console.Title = "Telesoftas wrapper"; Console.WriteLine("Wrapper is starting\n"); TextWrapper wrapper = new TextWrapper(); WrapperModel model = wrapper.PrepareWrapperModel(args); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine($"Line length: {model.Length}"); Console.WriteLine($"Original text: {model.Text}"); Console.ResetColor(); var wrapped = wrapper.WrapText(model); Console.WriteLine("\nWrapped:"); Console.ForegroundColor = ConsoleColor.DarkGreen; foreach (var l in wrapped) { Console.WriteLine(l); } Console.ResetColor(); } catch (Exception ex) { Logger.Fatal(ex, "Unexpected error fired."); Console.ForegroundColor = ConsoleColor.Red; Console.Write($"\nERROR: {ex.Message}"); Console.ResetColor(); } finally { Logger.Info("Application terminated."); Console.WriteLine("\nApplication terminated. Press <enter> to exit..."); Console.ReadLine(); } }
public WrapperModel PrepareWrapperModel(string[] args) { WrapperModel model = new WrapperModel(); string argText = string.Empty; string argLength = string.Empty; int indexL = Array.IndexOf(args, args.Where(x => x.Equals("-l"))?.FirstOrDefault()); int indexT = Array.IndexOf(args, args.Where(x => x.Equals("-t"))?.FirstOrDefault()); if (indexT > -1) { argText = args.ElementAtOrDefault(indexT + 1); } if (indexL > -1) { argLength = args.ElementAtOrDefault(indexL + 1); } model.Text = !string.IsNullOrEmpty(argText) ? argText : ReadInputFile(); int dummy; if (int.TryParse(argLength, out dummy) && dummy > 0) { model.Length = dummy; } else { throw new IndexOutOfRangeException("Line length is incorrect"); } if (string.IsNullOrEmpty(model.Text)) { throw new IndexOutOfRangeException("Text to wrap was not set"); } Logger.Debug("Prepared model:"); Logger.Debug($"Line length: {model.Length}"); Logger.Debug($"Text: {model.Text}"); return(model); }
//Veracode vulnerability CWE-918 mitigated as per the design in the portal. Ref:https://community.veracode.com/s/question/0D52T00004s161DSAQ/how-to-fix-cwe918-serverside-request-forgery-ssrf public HttpResponseMessage POSTSpecial(WrapperModel WrapperData, string apiKey) { SetHttpClient(client); var url = WrapperData.url; var URL_regex = new System.Text.RegularExpressions.Regex(URL_Validator); if (!URL_regex.Match(url).Success) { throw new ArgumentException("Invalid URL"); } client.BaseAddress = new System.Uri(url); client.DefaultRequestHeaders.TryAddWithoutValidation("x-api-key", apiKey); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); HttpContent content = new StringContent(WrapperData.content, UTF8Encoding.UTF8, "application/json"); var messge = client.PostAsync(url, content).Result; client = null; return(messge); }
public IActionResult DisplayUser(int uId) { if (HttpContext.Session.GetString("userName") == null) { return(RedirectToAction("Index")); } else { WrapperModel viewMod = new WrapperModel(); viewMod.User = dbContext.Users.Include(u => u.UserLikes).FirstOrDefault(u => u.UserId == (int)HttpContext.Session.GetInt32("userId")); viewMod.AllIdeas = dbContext.Ideas.Include(u => u.Creator).Include(i => i.IdeaLikes).Where(i => i.Creator.UserId == (int)HttpContext.Session.GetInt32("userId")).ToList(); int sum = 0; foreach (Idea idea in viewMod.AllIdeas) { sum += idea.IdeaLikes.Count; } viewMod.Count = sum; return(View(viewMod)); } }
public ActionResult SubmitOrder(WrapperModel 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)); } }
public IActionResult Register(WrapperModel WrappedUser) { User user = WrappedUser.NewUser; if (dbContext.Users.Any(u => u.Email == user.Email)) { ModelState.AddModelError("NewUser.Email", "Email already in use!"); } if (ModelState.IsValid) { PasswordHasher <User> Hasher = new PasswordHasher <User>(); user.Password = Hasher.HashPassword(user, user.Password); dbContext.Add(user); dbContext.SaveChanges(); HttpContext.Session.SetInt32("LoggedInUserID", user.UserId); return(RedirectToAction("Success")); } else { return(View("Index")); } }
public IActionResult createWedding(WrapperModel Wedding) { if (HttpContext.Session.GetInt32("UserID") == null) { return(View("Index")); } Wedding.newWedding.UserID = (int)HttpContext.Session.GetInt32("UserID"); if (ModelState.IsValid) { Wedding.newWedding.UserID = (int)HttpContext.Session.GetInt32("UserID"); dbContext.Add(Wedding.newWedding); dbContext.SaveChanges(); return(RedirectToAction("Dashboard")); } else { WrapperModel ViewModel = new WrapperModel(); ViewModel.newUser = dbContext.Users.FirstOrDefault(u => u.UserID == HttpContext.Session.GetInt32("UserID")); return(RedirectToAction("Dashboard")); } }
public IActionResult UpdateHobby(int HobbyID, WrapperModel eHobby) { if (HttpContext.Session.GetInt32("UserID") == null) { return(View("Index")); } if (ModelState.IsValid) { WrapperModel ViewModel = new WrapperModel(); Hobby UpdateHobby = dbContext.Hobbies.FirstOrDefault(h => h.HobbyID == HobbyID); UpdateHobby.Name = eHobby.newHobby.Name; UpdateHobby.Description = eHobby.newHobby.Description; UpdateHobby.UpdatedAt = DateTime.Now; UpdateHobby.CreatedAt = UpdateHobby.CreatedAt; dbContext.SaveChanges(); return(RedirectToAction("Dashboard")); } else { return(View("EditHobby")); } }
public IActionResult Dashboard() { if (HttpContext.Session.GetInt32("UserID") == null) { return(View("Index")); } else { WrapperModel ViewModel = new WrapperModel(); ViewModel.newUser = dbContext.Users.FirstOrDefault(u => u.UserID == HttpContext.Session.GetInt32("UserID")); ViewModel.allHobbies = dbContext.Hobbies .Include(u => u.Creator) .Include(u => u.Enthusiast) .OrderByDescending(t => t.Enthusiast.Count).ToList(); int count = 0; foreach (Hobby hobby in ViewModel.allHobbies) { count += hobby.Enthusiast.Count; } ViewModel.EnthusiastCount = count; return(View("Dashboard", ViewModel)); } }
public IActionResult Dashboard() { if (HttpContext.Session.GetInt32("UserID") == null) { return(View("Index")); } else { WrapperModel ViewModel = new WrapperModel(); ViewModel.newUser = dbContext.Users.FirstOrDefault(u => u.UserID == HttpContext.Session.GetInt32("UserID")); ViewModel.allWeddings = dbContext.Weddings .Include(u => u.Creator) .Include(u => u.WeddingGuest) .OrderByDescending(t => t.CreatedAt).ToList(); int count = 0; foreach (Wedding wedding in ViewModel.allWeddings) { count += wedding.WeddingGuest.Count; } ViewModel.guestCount = count; return(View("Dashboard", ViewModel)); } }
public IActionResult Dashboard() { if (HttpContext.Session.GetInt32("UserId") == null) { return(RedirectToAction("Index")); } int UserID = HttpContext.Session.GetInt32("UserId").Value; WrapperModel newModel = new WrapperModel(); newModel.LoggedInUser = dbContext.users.SingleOrDefault(u => u.UserId == UserID); newModel.AllOccasions = dbContext.occasions.OrderBy(o => o.Date).ThenBy(t => t.Time).Include(o => o.Attendants).ThenInclude(a => a.Person).ToList(); foreach (Occasion each in newModel.AllOccasions) { each.CoordinatorUser = dbContext.users.SingleOrDefault(u => u.UserId == each.CoordinatorId); var dateString = DateTime.Now.ToShortTimeString(); var eventString = each.Time.ToShortTimeString(); DateTime d1 = DateTime.Parse(dateString); DateTime d2 = DateTime.Parse(eventString); DateTime.Compare(d1, d2); } System.Console.WriteLine("********************"); System.Console.WriteLine(DateTime.Today); return(View(newModel)); }
public void SendEmail(WrapperModel model) { //Logic send the email to the client // }
public string SetUpbill(WrapperModel model) { WrapperModel m = new WrapperModel(); m.billing = model.billing; m.shipping = model.shipping; m.oligosequence = model.oligosequence; //headers //éé éé 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>Dear" + " " + model.shipping.FullName + " " + "here is your Oligonucleotide Order</h1></td></table>"; ship += "<table width='100' style='float:left' cellpadding='0' cellspacing='0' border='0' >"; ship += "<thead>"; ship += "<tr>"; ship += "<th style='color:blue;text-decoration: underline;'><h1>Shipping 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.shipping.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.shipping.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.shipping.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.shipping.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.shipping.Email; ship += "</td>"; ship += "</tr>"; ship += "</table>"; //Billing var bill = "<table width='100' style='float:left' cellpadding='0' cellspacing='0' border='0'>"; bill += "<thead>"; bill += "<tr>"; bill += "<th style='color:blue; text-decoration: underline;'><h1>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'>Billing 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 += "<td valign='top'>"; bill += "<label for='first_name'> Notes</label>"; bill += "</td>"; bill += "<td valign='top'>"; bill += m.billing.Notes; bill += "</td>"; bill += "</tr> </table>"; var olForm = "<div style='padding-top:500px'><h1 style='color:blue;text-decoration: underline;page-break-before:always'>Oligonucleotide Sequence</h1>"; olForm += "<table style='width:100%' border='1'>"; olForm += "<tr style='width:100%'>"; olForm += "<td class='boldCell'>PrimerName</td>"; olForm += "<td class='boldCell'>Qty</td>"; olForm += "<td class='boldCell'>OligonucleotideSequence</td>"; olForm += "<td class='boldCell'>SynthesisScale1</td>"; olForm += "<td class='boldCell'>GMP2</td>"; olForm += "<td class='boldCell'>Modification</td>"; olForm += "<td class='boldCell'>FinalDeliveryForm</td>"; olForm += "<td class='boldCell'>Purification</td>"; olForm += "<td class='boldCell'>Price</td>"; olForm += "<td class='boldCell'>OligoID</td>"; // more cells here as needed olForm += "</tr>"; for (int i = 0; i < m.oligosequence.Count(); i++) { olForm += "<tr>"; olForm += "<td class='boldCell'>" + m.oligosequence[i].PrimerName + "</td>"; olForm += "<td class='boldCell'>" + m.oligosequence[i].Qty + "</td>"; olForm += "<td class='boldCell'>" + CreateString(m.oligosequence[i].OligonucleotideSequence) + "</td>"; olForm += "<td class='boldCell'>" + m.oligosequence[i].SynthesisScaleValue + "</td>"; olForm += "<td class='boldCell'>" + m.oligosequence[i].GMP2 + "</td>"; olForm += "<td class='boldCell'>" + m.oligosequence[i].Modification + "</td>"; olForm += "<td class='boldCell'>" + m.oligosequence[i].FinalDeliveryFormValue + "</td>"; olForm += "<td class='boldCell'>" + m.oligosequence[i].PurificationValue + "</td>"; olForm += "<td class='boldCell'>" + m.oligosequence[i].Price + "</td>"; olForm += "<td class='boldCell'> </td>"; // more cells here as needed olForm += "</tr>"; } olForm += "</table> </div> </body> </html>"; var template = StaticValues.HtmlHeaderText() + ship + bill + olForm; CreateEmailForUser(m.shipping.Email, "*****@*****.**", template); CreateEmailForJason(m.shipping.Email, "", template); CreateEmailForAnders(m.shipping.Email, "*****@*****.**", template); return(olForm); }
public IHttpActionResult Post(WrapperModel model) { //Insert into database WrapperModel templateData = new WrapperModel(); List <Oligosequence> getList = new List <Oligosequence>(); 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); //Shipping Shipping ship = new Shipping(); ship.ShippingDate = model.shipping.ShippingDate; 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 Oligosequence ol; for (int i = 0; i < model.oligosequence.Count(); i++) { ol = new Oligosequence(); //Primer Name ol.PrimerName = model.oligosequence[i].PrimerName; //Qty ol.Qty = model.oligosequence[i].Qty; //OligonucleotideSequence ol.OligonucleotideSequence = model.oligosequence[i].OligonucleotideSequenceValue; //SynthesisScale1 ol.SynthesisScaleValue = model.oligosequence[i].SynthesisScaleValue; ol.FinalDeliveryFormValue = model.oligosequence[i].FinalDeliveryFormValue; ol.GMP2 = model.oligosequence[i].GMP2; ol.Modification = model.oligosequence[i].ModificationValue; ol.PurificationValue = model.oligosequence[i].PurificationValue; ol.Price = model.oligosequence[i].Price; ol.UserId = g; // db.Oligosequence.Add(ol); // db.Entry(ol).State = EntityState.Added; getList.Add(ol); } //Create email template! SendEmail email = new SendEmail(); templateData.oligosequence = getList; email.SetUpbill(templateData); // ParseTemplate(ob); // db.SaveChanges(); return(Ok()); } catch (Exception ex) { return(Ok(ex.InnerException.ToString())); } }
// public ActionResult GeneratePDF() { return new Rotativa.ActionAsPdf("Orders"); } private WrapperModel CreateOrder(WrapperModel model) { WrapperModel templateData = new WrapperModel(); List <Oligosequence> getList = new List <Oligosequence>(); 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); //Shipping Shipping ship = new Shipping(); ship.ShippingDate = model.shipping.ShippingDate; 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 Oligosequence ol; for (int i = 0; i < model.oligosequence.Count(); i++) { ol = new Oligosequence(); ////Primer Name //ol.PrimerName = model.oligosequence[i].PrimerName; ////Qty //ol.Qty = model.oligosequence[i].Qty; ////OligonucleotideSequence //ol.OligonucleotideSequence = model.oligosequence[i].OligonucleotideSequence; ////SynthesisScale1 //var getSynthesisScale1 = Core.StaticValues.SynthesisD.SingleOrDefault(x => x.Value == Convert.ToInt32(model.oligosequence[i].SynthesisScale1)); //ol.SynthesisScale1 = getSynthesisScale1.Key; //var final = Core.StaticValues.FinalDelivery.SingleOrDefault(x => x.Value == Convert.ToString(model.oligosequence[i].FinalDeliveryForm)); //ol.FinalDeliveryForm = final.Text; //ol.GMP2 = model.oligosequence[i].GMP2; //ol.Modification = model.oligosequence[i].Modification; //var purification = Core.StaticValues.Purification.SingleOrDefault(X => X.Value == model.oligosequence[i].Purification); //ol.Purification = purification.Text; //ol.UserId = g; //db.Oligosequence.Add(ol); //db.Entry(ol).State = EntityState.Added; getList.Add(ol); } //Create email template! SendEmail email = new SendEmail(); templateData.oligosequence = getList; email.SetUpbill(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); } }