public ActionResult AddImage(Image model, HttpPostedFileBase image1, HttpPostedFileBase image2, HttpPostedFileBase image3) { model.ModelID = id; var db = new DB18Entities1(); if (image1 != null) { model.Front = new byte[image1.ContentLength]; image1.InputStream.Read(model.Front, 0, image1.ContentLength); } if (image2 != null) { model.Back = new byte[image2.ContentLength]; image2.InputStream.Read(model.Back, 0, image2.ContentLength); } if (image3 != null) { model.Side = new byte[image3.ContentLength]; image3.InputStream.Read(model.Side, 0, image3.ContentLength); } db.Images.Add(model); db.SaveChanges(); return(View(model)); }
public ActionResult QMobile() { using (DB18Entities1 db = new DB18Entities1()) { List <Manufacturer> man = db.Manufacturers.ToList(); List <Series> ser = db.Series.ToList(); List <Model> mod = db.Models.ToList(); List <Feature> fea = db.Features.ToList(); List <Image> img = db.Images.ToList(); var m_recored = from m in man join s in ser on m.ManufacturerID equals s.ManufacturerID into table1 from s in table1.ToList() join md in mod on s.SeriesID equals md.SeriesID into table2 from md in table2.ToList() join f in fea on md.ModelID equals f.ModelID into table3 from f in table3.ToList() join i in img on md.ModelID equals i.ModelID into table4 from i in table4.ToList() select new SaveViewModel { model = md, manufacturer = m, series = s, features = f, image = i, }; return(View(m_recored)); } }
public ActionResult RetriveImage() { DB18Entities1 db = new DB18Entities1(); var item = (from d in db.Images select d).ToList(); return(View(item)); }
public ActionResult Insert_News(News_Add n) { using (DB18Entities1 db = new DB18Entities1()) { News nw = new News(); nw.Details = n.Details; db.News.Add(nw); db.SaveChanges(); ViewBag.saveresult = "saved"; ModelState.Clear(); } return(View(new News_Add())); }
public ActionResult Insert_info(Mobile_info m) { using (DB18Entities1 db = new DB18Entities1()) { Manufacturer mn = new Manufacturer(); mn.Name = m.Name; mn.Country = m.Country; db.Manufacturers.Add(mn); db.SaveChanges(); Series s = new Series(); s.Name = m.S_Name; s.ManufacturerID = mn.ManufacturerID; db.Series.Add(s); db.SaveChanges(); Model md = new Model(); md.Name = m.M_Name; md.SeriesID = s.SeriesID; md.Launch_Date = m.Launch_Date; md.Price = m.Price; db.Models.Add(md); db.SaveChanges(); id = md.ModelID; Feature f = new Feature(); f.ModelID = md.ModelID; f.Network = m.Network; f.Front_Cam = m.Front_Cam; f.Back_Cam = m.Back_Cam; f.Sim = m.Sim; f.Ram = m.Ram; f.Operating_System = m.Operating_System; f.Screen_Size = m.Screen_Size; f.Frequency = m.Frequency; f.Bettery = m.Bettery; f.Color = m.Color; db.Features.Add(f); db.SaveChanges(); ViewBag.saveresult = "saved"; ModelState.Clear(); } return(View(new Mobile_info())); }
public ActionResult Contact(Feedback_Model f) { using (DB18Entities1 db = new DB18Entities1()) { FeedBack fb = new FeedBack(); fb.Name = f.Name; fb.Email = f.Email; fb.Message = f.Message; db.FeedBacks.Add(fb); db.SaveChanges(); ViewBag.saveresult = "saved"; ModelState.Clear(); } return(View(new Feedback_Model())); }
public ActionResult Authorize(Example.Models.Admin user) { using (DB18Entities1 db = new DB18Entities1()) { var UserInput = db.Admins.Where(b => b.Email == user.Email && b.Password == user.Password).FirstOrDefault(); if (UserInput == null) { user.LoginErrorMessage = "Username or Password Doesn't Exist"; return(View("Index", user)); } else { // session is a state that is used to store and retrieve values of a user. // Session["AdminId"] = UserInput.AdminID; Session["Email"] = UserInput.Email.ToString(); Session["Password"] = UserInput.Password.ToString(); return(RedirectToAction("Insert_info", "SaveData")); } } }