public ActionResult Add() { Session["Lang"] = 1; Adses ads = new Adses(); return(View(ads)); }
public ActionResult Delete(int id) { try { if (Session["Active"].ToString() != "1") { return(RedirectToAction("login", "account")); } } catch { return(RedirectToAction("login", "account")); } Adses ad = db.Adses.FirstOrDefault(m => m.ID == id); ViewBag.ID = ad.ID; string a = ad.User_Id.ToString(); string b = Session["us"].ToString(); if (a != b) { return(RedirectToAction("login", "account")); } Session["Lang"] = 2; return(View(db.Adses.Find(id))); }
public ActionResult Add() { try { if (Session["Active"].ToString() != "1") { return(RedirectToAction("Login", "Home")); } } catch { return(RedirectToAction("Login", "Home")); } ViewBag.StateList = db.Regions; ViewBag.RubricList = db.Rubric; ViewBag.Id = Session["User"].ToString(); int id = Int32.Parse(ViewBag.Id); Users u = db.Users.FirstOrDefault(x => x.ID == id); ViewBag.Usertype = u.Type; var model = new Adses(); return(View(model)); }
public ActionResult Add(Adses ad, HttpPostedFileBase file) { ViewBag.StateList = db.Regions; ViewBag.RubricList = db.Rubric; ad.Date = DateTime.Now; ad.User_ID = Convert.ToInt32(Session["User"]); ad.State_ID = 2; string path = Path.Combine(Server.MapPath("~/Content/img/"), Path.GetFileName(file.FileName)); file.SaveAs(path); path = Path.Combine(Server.MapPath("~/Content/img/"), Path.GetFileName(file.FileName)); file.SaveAs(path); ad.Picture = "/Content/img/" + file.FileName; db.Adses.Add(ad); db.SaveChanges(); return(RedirectToAction("ProductList", "Home")); }
public ActionResult AddProduct() { ViewBag.StateList = db.Regions; ViewBag.RubricList = db.Rubric; var model = new Adses(); return(View(model)); }
public ActionResult Delete(Adses ad) { Adses a = db.Adses.FirstOrDefault(x => x.ID == ad.ID); db.Adses.Remove(a); db.SaveChanges(); return(RedirectToAction("PersonalCabinet")); }
public ActionResult ProductDelete(Adses ads) { Adses a = db.Adses.FirstOrDefault(x => x.Id == ads.Id); db.Adses.Remove(a); db.SaveChanges(); return(RedirectToAction("ProductList", "Home")); }
public ActionResult ProductEdit(Adses ads) { Adses ad = db.Adses.FirstOrDefault(x => x.Id == ads.Id); ad = ads; db.Entry(ad); db.SaveChanges(); return(RedirectToAction("ProductList", "Home")); }
public ActionResult Rejection(int id) { Adses a = db.Adses.FirstOrDefault(x => x.Id == id); a.Date = DateTime.Now; a.State_ID = 5; db.Entry(a); db.SaveChanges(); return(RedirectToAction("Productlist")); }
public ActionResult Details(Adses a) { Adses aa = db.Adses.FirstOrDefault(x => x.ID == a.ID); if (aa.Sales == 3) { aa.Date = DateTime.Now; aa.Sales = 1; } db.Entry(aa); db.SaveChanges(); return(RedirectToAction("IndexNew")); }
public ActionResult Edit(Adses ad) { Adses ads = db.Adses.FirstOrDefault(x => x.ID == ad.ID); if (ads.Sales == 5) { ads.Sales = 4; } ads.CountRooms = ad.CountRooms; ads.Address = ad.Address; ads.All_Floor = ad.All_Floor; ads.Area_Id = ad.Area_Id; ads.Build_Id = ad.Build_Id; ads.Classification_Id = ad.Classification_Id; ads.Comissions = ad.Comissions; if (ad.Contacts_Id == null) { ads.Contacts_Id = 2; } ads.Floor = ad.Floor; ads.Furniture = ad.Furniture; if (ad.Images != null) { ads.Images = ad.Images; } ads.LivePlace = ad.LivePlace; ads.Operation_Id = ad.Operation_Id; ads.PhoneNumber = ad.PhoneNumber; ads.Price = ad.Price; ads.PriceType_Id = ad.PriceType_Id; ads.Property_Id = ad.Property_Id; ads.ShortText = ad.ShortText; ads.SquarePlace = ad.SquarePlace; ads.State_Id = ad.State_Id; ads.Title = ad.Title; if (ad.Top_Ads == null) { ads.Top_Ads = 2; } ads.Zone_Id = ad.Zone_Id; ads.Accept_Rejection = 0; ads.Date = DateTime.Now; db.Entry(ads); db.SaveChangesAsync(); return(RedirectToAction("PersonalCabinet")); }
public ActionResult Edit(Adses ph) { Adses p = db.Adses.FirstOrDefault(x => x.ID == ph.ID); p.CountRooms = ph.CountRooms; p.Address = ph.Address; p.All_Floor = ph.All_Floor; p.Area_Id = ph.Area_Id; p.Build_Id = ph.Build_Id; p.Classification_Id = ph.Classification_Id; p.Comissions = ph.Comissions; if (ph.Contacts_Id == null) { p.Contacts_Id = 2; } p.Floor = ph.Floor; p.Furniture = ph.Furniture; if (ph.Images != null) { p.Images = ph.Images; } p.LivePlace = ph.LivePlace; p.Operation_Id = ph.Operation_Id; p.PhoneNumber = ph.PhoneNumber; p.Price = ph.Price; p.PriceType_Id = ph.PriceType_Id; p.Property_Id = ph.Property_Id; p.ShortText = ph.ShortText; p.SquarePlace = ph.SquarePlace; p.State_Id = ph.State_Id; p.Title = ph.Title; if (ph.Top_Ads == null) { p.Top_Ads = 2; } p.Zone_Id = ph.Zone_Id; db.Entry(p); db.SaveChangesAsync(); if (p.Sales == 2) { return(RedirectToAction("IndexNew")); } else { return(RedirectToAction("IndexOld")); } }
public ActionResult Rejection(Adses a) { Adses aa = db.Adses.FirstOrDefault(x => x.ID == a.ID); aa.Sales = 5; aa.Date = DateTime.Now; try { aa.About_Mistake = a.About_Mistake; } catch { } db.Entry(aa); db.SaveChanges(); return(RedirectToAction("newAdses")); }
public ActionResult Buy(int id) { Adses a = db.Adses.FirstOrDefault(x => x.ID == id); a.Date = DateTime.Now; db.Entry(a); db.SaveChanges(); if (a.Sales == 2) { a.Sales = 1; return(RedirectToAction("IndexNew")); } else { return(RedirectToAction("IndexOld")); } }
public ActionResult Except(int id) { Adses a = db.Adses.FirstOrDefault(x => x.ID == id); a.Sales = 2; a.Date = DateTime.Now; db.Entry(a); db.SaveChanges(); if (a.Sales == 3) { return(RedirectToAction("IndexOld")); } else { return(RedirectToAction("newAdses")); } }
public ActionResult Delete(Adses ph) { Adses a = db.Adses.FirstOrDefault(x => x.ID == ph.ID); db.Adses.Remove(a); db.SaveChanges(); if (a.Sales == 3) { return(RedirectToAction("IndexOld")); } else if (a.Sales == 1) { return(RedirectToAction("Sales_Ads")); } else { return(RedirectToAction("IndexNew")); } }
public ActionResult AddProduct(Adses ad, HttpPostedFileBase file) { ViewBag.StateList = db.Regions; ViewBag.RubricList = db.Rubric; ad.Date = DateTime.Now; ad.User_ID = 1; ad.State_ID = 1; string path = Path.Combine(Server.MapPath("~/Content/img/"), Path.GetFileName(file.FileName)); file.SaveAs(path); path = Path.Combine(Server.MapPath("~/Content/img/"), Path.GetFileName(file.FileName)); file.SaveAs(path); ad.Picture = "/Content/img/" + file.FileName; db.Adses.Add(ad); db.SaveChanges(); return(View(ad)); }
public ActionResult ProductEdit(int id) { Adses ads = db.Adses.Find(id); ViewBag.StateList = db.Regions; ViewBag.RubricList = db.Rubric; var list = new List <Areas>(); foreach (var item in db.Areas) { if (item.Region_Id == ads.Region_Id) { list.Add(item); } } ViewBag.AreaList = list; var list2 = new List <Type_Product>(); foreach (var item in db.Type_Product) { if (item.Rubric_Id == ads.Rubric_Id) { list2.Add(item); } } ViewBag.maxsulotList = list2; return(View(db.Adses.Find(id))); }
public ActionResult AddHome() { try { if (Session["Active"].ToString() != "1") { return(RedirectToAction("login", "account")); } } catch { return(RedirectToAction("login", "account")); } Session["Lang"] = 1; ViewBag.Id = Session["User"].ToString(); int id = Int32.Parse(ViewBag.Id); int count = 0; Users u = db.Users.FirstOrDefault(x => x.ID == id); ViewBag.Usertype = u.UserType; if (u.UserType == 3) { count = db.Adses.Where(x => x.User_Id == id).Count(); } if (count >= 2) { return(RedirectToAction("about", "home")); } Adses ads = new Adses(); return(View()); }
public ActionResult ProductEdit(Adses ads, HttpPostedFileBase file) { string path = Path.Combine(Server.MapPath("~/Content/img/"), Path.GetFileName(file.FileName)); file.SaveAs(path); path = Path.Combine(Server.MapPath("~/Content/img/"), Path.GetFileName(file.FileName)); file.SaveAs(path); foreach (var std in db.Adses) { if (std.Id == ads.Id) { std.Picture = file.FileName == null ? std.Picture : "/Content/img/" + file.FileName; std.Price = ads.Price == null ? std.Price : ads.Price; std.Region_Id = ads.Region_Id == null ? std.Region_Id : ads.Region_Id; std.Rubric_Id = ads.Rubric_Id == null ? std.Rubric_Id : ads.Rubric_Id; std.Short_text = ads.Short_text == null ? std.Short_text : ads.Short_text; std.State_ID = ads.State_ID == null ? std.State_ID : ads.State_ID; std.Title = ads.Title == null ? std.Title : ads.Title; std.TypeAdses = ads.TypeAdses == null ? std.TypeAdses : ads.TypeAdses; std.TypeProduct_Id = ads.TypeProduct_Id == null ? std.TypeProduct_Id : ads.TypeProduct_Id; std.User_ID = ads.User_ID == null ? std.User_ID : ads.User_ID; std.Area_Id = ads.Area_Id == null ? std.Area_Id : ads.Area_Id; std.CountView = ads.CountView == null ? std.CountView : ads.CountView; std.Date = ads.Date == null ? std.Date : ads.Date; } } db.SaveChanges(); return(RedirectToAction("ProductList", "Admin")); }
public ActionResult Add(Adses ads, HttpPostedFileBase[] Images) { string s = ""; int count = 0; ads.Property_Id = 1; ads.Sales = 2; ads.Assignment_Id = 0; ads.About_Mistake = "0"; if (ads.Contacts_Id == null) { ads.Contacts_Id = 2; } if (ads.LivePlace == null) { ads.LivePlace = Convert.ToString(0); } if (ads.Metro_Id == null) { ads.Metro_Id = 0; } if (ads.Top_Ads == null) { ads.Top_Ads = 2; } if (ads.Price_Real == null) { ads.Price_Real = 0; } ads.Date = DateTime.Now; ads.User_Id = 1; ads.Accept_Rejection = 0; db.Adses.Add(ads); db.SaveChanges(); foreach (HttpPostedFileBase files in Images) { if (count > 8) { break; } count++; //Checking file is available to save. if (files != null) { var InputFileName = Path.GetFileName(files.FileName); var ServerSavePath = Path.Combine(Server.MapPath("~/UploadedFiles/") + ads.ID + "-" + InputFileName); s += Convert.ToString(ads.ID) + "-" + InputFileName + ","; //Save file to server folder files.SaveAs(ServerSavePath); //assigning file uploaded status to ViewBag for showing message to user. ViewBag.UploadStatus = Images.Count().ToString() + " files uploaded successfully."; } else { s = "0"; break; } } ads.Images = s; db.Entry(ads); db.SaveChanges(); return(RedirectToAction("Add", "Cabinet")); }
public ActionResult AddHome(Adses ads, HttpPostedFileBase[] Images) { string s = ""; int count = 0; ViewBag.Id = Session["User"].ToString(); ads.Property_Id = 1; ads.Sales = 4; ads.Assignment_Id = 0; ads.About_Mistake = "0"; if (ads.Contacts_Id == null) { ads.Contacts_Id = 2; } if (ads.LivePlace == null) { ads.LivePlace = Convert.ToString(0); } if (ads.Metro_Id == null) { ads.Metro_Id = 0; } if (ads.Top_Ads == null) { ads.Top_Ads = 2; } ads.Date = DateTime.Now; ads.User_Id = Int32.Parse(ViewBag.Id); ads.Accept_Rejection = 0; db.Adses.Add(ads); db.SaveChanges(); //iterating through multiple file collection foreach (HttpPostedFileBase file in Images) { //Checking file is available to save. if (file != null) { // 8 ta rasm oladi if (count > 8) { break; } count++; var InputFileName = Path.GetFileName(file.FileName); var ServerSavePath = Path.Combine(Server.MapPath("~/UploadedFiles/") + ads.ID + "-" + InputFileName); s += Convert.ToString(ads.ID) + "-" + InputFileName + ","; //Save file to server folder file.SaveAs(ServerSavePath); //assigning file uploaded status to ViewBag for showing message to user. ViewBag.UploadStatus = Images.Count().ToString() + " files uploaded successfully."; } else { s = "0"; break; } } ads.Images = s; db.Entry(ads); db.SaveChanges(); return(RedirectToAction("PersonalCabinet", "Home")); }