public ActionResult Create([Bind(Include = "stor_id,ord_num,ord_date,qty,payterms,title_id")] sale sale) { if (ModelState.IsValid) { var test = db.sales.Find(sale.stor_id, sale.ord_num, sale.title_id); //find if stor_id (prim key's) already exists if (test == null) { db.sales.Add(sale); try { db.SaveChanges(); } catch (Exception e) { return(RedirectToAction("../Home/Error")); } } else //value already exists { return(RedirectToAction("../Home/Error")); } return(RedirectToAction("Index")); } ViewBag.stor_id = new SelectList(db.stores, "stor_id", "stor_name", sale.stor_id); ViewBag.title_id = new SelectList(db.titles, "title_id", "title1", sale.title_id); ViewBag.ord_num = new SelectList(db.sales, "ord_num", "ord_num", sale.ord_num); return(View(sale)); }
public ActionResult Create([Bind(Include = "stor_id,stor_name,stor_address,city,state,zip")] store store) { if (ModelState.IsValid) { var test = db.stores.Find(store.stor_id); //find if stor_id (prim key's) already exists if (test == null) { db.stores.Add(store); try { db.SaveChanges(); } catch (Exception e) { return(RedirectToAction("../Home/Error")); } } else { return(RedirectToAction("../Home/Error")); } return(RedirectToAction("Index")); } return(View(store)); }
public ActionResult Create([Bind(Include = "title_id,title1,type,pub_id,price,advance,royalty,ytd_sales,notes,pubdate")] title titles) { if (ModelState.IsValid) { var test = db.titles.Find(titles.title_id); //find if title_id (prim key's) already exists if (test == null) { //they won't execute due to the reason that those fields are required. probably there is another way to set default values for required fields /*if (titles.type == "") titles.type = "UNDECIDED"; if (titles.pubdate == null) titles.pubdate = DateTime.Now; */ db.titles.Add(titles); try { db.SaveChanges(); } catch (Exception e) { return RedirectToAction("../Home/Error"); } } else //value already exists return RedirectToAction("../Home/Error"); return RedirectToAction("Index"); } ViewBag.pub_id = new SelectList(db.publishers, "pub_id", "pub_name", titles.pub_id); ViewBag.title_id = new SelectList(db.royscheds, "title_id", "title_id", titles.title_id); return View(titles); }
public ActionResult Create([Bind(Include = "job_id,job_desc,min_lvl,max_lvl")] job job) { if (ModelState.IsValid) { var test = db.jobs.Find(job.job_id); //find if job_id (prim key's) already exists if (test == null) { if (job.job_desc == "") { job.job_desc = "New Position - title not formalized yet"; } db.jobs.Add(job); try { db.SaveChanges(); } catch (Exception e) { return(RedirectToAction("../Home/Error")); } } else { return(RedirectToAction("../Home/Error")); } return(RedirectToAction("Index")); } return(View(job)); }
public ActionResult Create([Bind(Include = "pub_id,pub_name,city,state,country")] publisher publisher) { var test = db.publishers.Find(publisher.pub_id); //find if pub_id (prim key) already exists if (ModelState.IsValid) { if (test == null) { if (publisher.country == "") { publisher.country = "USA"; } db.publishers.Add(publisher); try { db.SaveChanges(); } catch (Exception e) { return(RedirectToAction("../Home/Error")); } } else //value already exists { return(RedirectToAction("../Home/Error")); } return(RedirectToAction("Index")); } ViewBag.pub_id = new SelectList(db.pub_info, "pub_id", "pr_info", publisher.pub_id); return(View(publisher)); }
public ActionResult Create([Bind(Include = "au_id,au_lname,au_fname,phone,address,city,state,zip,contract")] author author) { if (ModelState.IsValid) { var test = db.authors.Find(author.au_id); //find if au_id (prim key's) already exists if (test == null) { if (author.phone == "") { author.phone = "UNKNOWN"; } db.authors.Add(author); try { db.SaveChanges(); } catch (Exception e) { return(RedirectToAction("../Home/Error")); } } else { return(RedirectToAction("../Home/Error")); } return(RedirectToAction("Index")); } return(View(author)); }
public ActionResult Create([Bind(Include = "pub_id,logo,pr_info")] pub_info pub_info) { if (ModelState.IsValid) { var test = db.pub_info.Find(pub_info.pub_id); //find if pub_id (prim key's) already exists if (test == null) { db.pub_info.Add(pub_info); try { db.SaveChanges(); } catch (Exception e) { return(RedirectToAction("../Home/Error")); } } else { return(RedirectToAction("../Home/Error")); } return(RedirectToAction("Index")); } ViewBag.pub_id = new SelectList(db.publishers, "pub_id", "pub_name", pub_info.pub_id); return(View(pub_info)); }
public ActionResult Create([Bind(Include = "au_id,title_id,au_ord,royaltyper")] titleauthor titleauthor) { if (ModelState.IsValid) { var test = db.titleauthors.Find(titleauthor.au_id, titleauthor.title_id); //find if au_id and title_id (prim key's) already exists as a combination if (test == null) { db.titleauthors.Add(titleauthor); try { db.SaveChanges(); } catch (Exception e) //sql exception { return(RedirectToAction("../Home/Error")); } } else //value already exists { return(RedirectToAction("../Home/Error")); } return(RedirectToAction("Index")); } ViewBag.au_id = new SelectList(db.authors, "au_id", "au_lname", titleauthor.au_id); ViewBag.title_id = new SelectList(db.titles, "title_id", "title1", titleauthor.title_id); return(View(titleauthor)); }
public ActionResult Create([Bind(Include = "stor_id,stor_name,stor_address,city,state,zip")] store store) { if (ModelState.IsValid) { db.stores.Add(store); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(store)); }
public ActionResult Create([Bind(Include = "au_id,au_lname,au_fname,phone,address,city,state,zip,contract")] authors authors) { if (ModelState.IsValid) { db.authors.Add(authors); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(authors)); }
public ActionResult Create([Bind(Include = "job_id,job_desc,min_lvl,max_lvl")] jobs jobs) { if (ModelState.IsValid) { db.jobs.Add(jobs); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(jobs)); }
public ActionResult Create([Bind(Include = "discounttype,stor_id,lowqty,highqty,discount1")] discount discount) { if (ModelState.IsValid) { db.discounts.Add(discount); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.stor_id = new SelectList(db.stores, "stor_id", "stor_name", discount.stor_id); return(View(discount)); }
public ActionResult Create([Bind(Include = "pub_id,pub_name,city,state,country")] publishers publishers) { if (ModelState.IsValid) { db.publishers.Add(publishers); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.pub_id = new SelectList(db.pub_info, "pub_id", "pr_info", publishers.pub_id); return(View(publishers)); }
public ActionResult Create([Bind(Include = "pub_id,logo,pr_info")] pub_info pub_info) { if (ModelState.IsValid) { db.pub_info.Add(pub_info); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.pub_id = new SelectList(db.publishers, "pub_id", "pub_name", pub_info.pub_id); return(View(pub_info)); }
public ActionResult Create([Bind(Include = "title_id,lorange,hirange,royalty")] roysched roysched) { if (ModelState.IsValid) { db.royscheds.Add(roysched); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.title_id = new SelectList(db.titles, "title_id", "title1", roysched.title_id); return View(roysched); }
public ActionResult Create([Bind(Include = "stor_id,ord_num,ord_date,qty,payterms,title_id")] sales sales) { if (ModelState.IsValid) { db.sales.Add(sales); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.stor_id = new SelectList(db.stores, "stor_id", "stor_name", sales.stor_id); ViewBag.title_id = new SelectList(db.titles, "title_id", "title", sales.title_id); return(View(sales)); }
public ActionResult Create([Bind(Include = "au_id,title_id,au_ord,royaltyper")] titleauthor titleauthor) { if (ModelState.IsValid) { db.titleauthors.Add(titleauthor); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.au_id = new SelectList(db.authors, "au_id", "au_lname", titleauthor.au_id); ViewBag.title_id = new SelectList(db.titles, "title_id", "title1", titleauthor.title_id); return(View(titleauthor)); }
public ActionResult Create([Bind(Include = "emp_id,fname,minit,lname,job_id,job_lvl,pub_id,hire_date")] employee employee) { if (ModelState.IsValid) { db.employee.Add(employee); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.job_id = new SelectList(db.jobs, "job_id", "job_desc", employee.job_id); ViewBag.pub_id = new SelectList(db.publishers, "pub_id", "pub_name", employee.pub_id); return(View(employee)); }
public ActionResult Create([Bind(Include = "title_id,title1,type,pub_id,price,advance,royalty,ytd_sales,notes,pubdate")] title title) { if (ModelState.IsValid) { db.titles.Add(title); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.pub_id = new SelectList(db.publishers, "pub_id", "pub_name", title.pub_id); ViewBag.title_id = new SelectList(db.royscheds, "title_id", "title_id", title.title_id); return(View(title)); }
public ActionResult Create([Bind(Include = "job_id,job_desc,min_lvl,max_lvl")] job job) { if (ModelState.IsValid) { db.jobs.Add(job); db.SaveChanges(); TempData["message_css"] = "alert alert-success"; TempData["message"] = "Successful"; return(RedirectToAction("Index")); } TempData["message_css"] = "alert alert-danger"; TempData["message"] = "Invalid input"; return(View(job)); }
public ActionResult Create([Bind(Include = "au_id,au_lname,au_fname,phone,address,city,state,zip,contract")] author author) { if (ModelState.IsValid) { db.authors.Add(author); db.SaveChanges(); TempData["message_css"] = "alert alert-success"; TempData["message"] = "Sucessful"; return(RedirectToAction("Index")); } TempData["message_css"] = "alert alert-danger"; TempData["message"] = "Invalid input"; return(View(author)); }
public ActionResult Create([Bind(Include = "stor_id,stor_name,stor_address,city,state,zip")] store store) { if (ModelState.IsValid) { db.stores.Add(store); db.SaveChanges(); TempData["message_css"] = "alert alert-success"; TempData["message"] = "Successful"; return(RedirectToAction("Index")); } TempData["message_css"] = "alert alert-danger"; TempData["message"] = "Invalid input"; return(View(store)); }
public ActionResult Create([Bind(Include = "pub_id,pub_name,city,state,country")] publisher publisher) { if (ModelState.IsValid) { db.publishers.Add(publisher); db.SaveChanges(); TempData["message_css"] = "alert alert-success"; TempData["message"] = "Successful"; return(RedirectToAction("Index")); } ViewBag.pub_id = new SelectList(db.pub_info, "pub_id", "pr_info", publisher.pub_id); TempData["message_css"] = "alert alert-danger"; TempData["message"] = "Invalid input"; return(View(publisher)); }
public ActionResult Create(author author) { author.au_id = author.phone; author.contract = true; if (ModelState.IsValid) { db.authors.Add(author); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(author)); }
public static void AlertSMS(string Message) { pubsEntities dbctx = new pubsEntities(); try { int AlertUsersCount = Convert.ToInt16(System.Configuration.ConfigurationSettings.AppSettings["AlertUsers"]); string AlertMSISDNKey = "AlertMSISDN"; List <string> AlertMSISDNs = new List <string>(); for (int i = 1; i <= AlertUsersCount; i++) { string AlertMSISDN = System.Configuration.ConfigurationSettings.AppSettings[AlertMSISDNKey + i.ToString()]; AlertMSISDNs.Add(AlertMSISDN); } foreach (string MSISDN in AlertMSISDNs) { dbctx.receives.Add(new receive { prefix = "RG", message = Message, scode = "96900", sender = MSISDN, dates = DateTime.Now.ToShortDateString(), times = DateTime.Now.ToShortTimeString(), flag = "NO" }); } dbctx.SaveChanges(); } catch (Exception ex) { log.Warn(ex.Message + " " + (ex.InnerException != null ? ex.InnerException.ToString() : "") + " " + " Some Issue at the Database Interaction. Alert SMS not sent!"); } }
public ActionResult Create([Bind(Include = "stor_id,ord_num,ord_date,qty,payterms,title_id")] sale sale) { if (ModelState.IsValid) { db.sales.Add(sale); db.SaveChanges(); TempData["message_css"] = "alert alert-success"; TempData["message"] = "Successful"; return(RedirectToAction("Index")); } ViewBag.stor_id = new SelectList(db.stores, "stor_id", "stor_name", sale.stor_id); ViewBag.title_id = new SelectList(db.titles, "title_id", "title1", sale.title_id); TempData["message_css"] = "alert alert-danger"; TempData["message"] = "Invalid input"; return(View(sale)); }
public void SavePublisher(string pubID, string name, string city) { Validate._Error e = new Validate._Error(); e.Msg = string.Empty; e.Caught = false; if (!Validate.IsFieldPopulated(name.Trim())) { e = Validate.UpdateErrorObject(e, "Publisher name cannot be blank.", true); } else { if (!Validate.IsStringShortEnough(name, 40)) { e = Validate.UpdateErrorObject(e, "Publisher name cannot be longer than 40 characters.", true); } } if (!Validate.IsStringShortEnough(city, 20)) { e = Validate.UpdateErrorObject(e, "City cannot be more than 20 characters.", true); } //If errors caught then throw exception with error message if (e.Caught) { throw new Exception(e.Msg); } //if we made it this far then no errors found using (pubsEntities context = new pubsEntities()) { publisher pub = context.publishers.FirstOrDefault(x => x.pub_id == pubID); pub.pub_name = name.Trim(); pub.city = city.Trim(); context.publishers.ApplyCurrentValues(pub); context.SaveChanges(); } }
public ActionResult Create([Bind(Include = "emp_id,fname,minit,lname,job_id,job_lvl,pub_id,hire_date")] employee employee) { if (ModelState.IsValid) { db.employees.Add(employee); db.SaveChanges(); TempData["message_css"] = "alert alert-success"; TempData["message"] = "Successful"; return(RedirectToAction("Index")); } ViewBag.job_id = new SelectList(db.jobs, "job_id", "job_desc", employee.job_id); ViewBag.pub_id = new SelectList(db.publishers, "pub_id", "pub_name", employee.pub_id); TempData["message_css"] = "alert alert-danger"; TempData["message"] = "Invalid input"; return(View(employee)); }
public ActionResult Create([Bind(Include = "discounttype,stor_id,lowqty,highqty,discount1")] discount discounts) { if (ModelState.IsValid) { db.discounts.Add(discounts); try { db.SaveChanges(); } catch (Exception e) { return(RedirectToAction("../Home/Error")); } return(RedirectToAction("Index")); } ViewBag.stor_id = new SelectList(db.stores, "stor_id", "stor_name", discounts.stor_id); return(View(discounts)); }
public ActionResult Create([Bind(Include = "title_id,lorange,hirange,royalty")] roysched roysched) { if (ModelState.IsValid) { db.royscheds.Add(roysched); try { db.SaveChanges(); } catch (Exception e) { return(RedirectToAction("../Home/Error")); } return(RedirectToAction("Index")); } ViewBag.title_id = new SelectList(db.titles, "title_id", "title1", roysched.title_id); return(View(roysched)); }