public ActionResult Edit(int id, PROPERTY p) { var product = model.PROPERTies.FirstOrDefault(x => x.ID == id); product.PropertyName = p.PropertyName; product.Avatar = p.Avatar; product.Images = p.Images; product.PropertyType_ID = p.PropertyType_ID; product.Content = p.Content; product.Street_ID = p.Street_ID; product.Ward_ID = p.Ward_ID; product.District_ID = p.District_ID; product.Price = p.Price; product.UnitPrice = p.UnitPrice; product.Area = p.Area; product.BedRoom = p.BedRoom; product.BathRoom = p.BathRoom; product.UserID = p.UserID; product.PackingPlace = p.PackingPlace; product.Created_at = p.Created_at; product.Create_post = p.Create_post; product.Status_ID = p.Status_ID; product.Note = p.Note; product.Updated_at = p.Updated_at; product.Sale_ID = p.Sale_ID; model.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult CreateNewProperty(PROPERTY property) { if (Session["UserID"] != null) { property.Avatar = AvatarUPost(property); property.Images = ImagesUPost(property); property.Created_at = DateTime.Now; property.Create_post = DateTime.Now; property.UnitPrice = "VND"; property.Status_ID = 1; property.UserID = int.Parse(Session["UserID"].ToString()); if (ModelState.IsValid) { db.PROPERTY.Add(property); db.SaveChanges(); return(RedirectToAction("ViewListMyProject", "AgencyProperty")); } ViewBag.District_ID = new SelectList(db.DISTRICT, "ID", "DistrictName", property.District_ID); ViewBag.Status_ID = new SelectList(db.PROJECT_STATUS, "ID", "Status_Name", property.Status_ID); ViewBag.PropertyType_ID = new SelectList(db.PROPERTY_TYPE, "ID", "CodeType", property.PropertyType_ID); ViewBag.Street_ID = new SelectList(db.STREET, "ID", "StreetName", property.Street_ID); ViewBag.UserID = new SelectList(db.USER, "ID", "Email", property.UserID); ViewBag.Sale_ID = new SelectList(db.USER, "ID", "Email", property.Sale_ID); ViewBag.Ward_ID = new SelectList(db.WARD, "ID", "WardName", property.Ward_ID); return(View(property)); } else { return(RedirectToAction("Login", "Account", new { area = "" })); } }
//public ProjectDriver(SearchResultState context) //{ // _context = context; //} public void InsertProjecttoDB(Table givenProjects) { using (var db = new DemoPPCRentalEntities()) { foreach (var row in givenProjects.Rows) { var property = new PROPERTY { PropertyName = row["PropertyName"], PropertyType_ID = db.PROPERTY_TYPE.ToList().FirstOrDefault(x => x.CodeType == row["PropertyType"]).ID, Status_ID = db.PROJECT_STATUS.ToList().FirstOrDefault(x => x.Status_Name == row["Status"]).ID, District_ID = db.DISTRICT.ToList().FirstOrDefault(x => x.DistrictName == row["District"]).ID, Street_ID = db.STREET.ToList().FirstOrDefault(x => x.StreetName == row["Street"]).ID, Content = row["Content"], UserID = db.USER.ToList().FirstOrDefault(x => x.FullName == row["Agency"]).ID, Sale_ID = db.USER.ToList().FirstOrDefault(x => x.FullName == row["Sale"]).ID, Avatar = row["Avarta"], Images = row["Images"], BedRoom = int.Parse(row["BedRoom"]), BathRoom = int.Parse(row["BathRoom"]), PackingPlace = int.Parse(row["PackingPlace"]), Price = int.Parse(row["Price"]), Area = row["Area"], }; //_context.ReferenceBooks.Add( // givenProjects.Header.Contains("ID") ? row["ID"] : row["PropertyName"], // property); db.PROPERTY.Add(property); } db.SaveChanges(); } }
public ActionResult CreateNewProperty(PROPERTY property) { if (Session["UserID"] != null) { property.Avatar = AvatarUPost(property); property.Images = ImagesUPost(property); property.Created_at = DateTime.Now; property.Create_post = DateTime.Now; property.UnitPrice = "VND"; property.Status_ID = 1; property.UserID = int.Parse(Session["UserID"].ToString()); if (ModelState.IsValid) { db.PROPERTY.Add(property); db.SaveChanges(); var features = Request.Form.AllKeys.Where(k => k.StartsWith("Feature_")); foreach (var feature in features) { var id = int.Parse(feature.Split('_')[1]); if (Request.Form[feature].StartsWith("true")) { db.PROPERTY_FEATURE.Add(new PROPERTY_FEATURE { Property_ID = property.ID, Feature_ID = id }); } } return(RedirectToAction("ViewListMyProject", "AgencyProperty")); } ViewBag.District_ID = new SelectList(db.DISTRICT, "ID", "DistrictName", property.District_ID); ViewBag.Status_ID = new SelectList(db.PROJECT_STATUS, "ID", "Status_Name", property.Status_ID); ViewBag.PropertyType_ID = new SelectList(db.PROPERTY_TYPE, "ID", "CodeType", property.PropertyType_ID); ViewBag.Street_ID = new SelectList(db.STREET, "ID", "StreetName", property.Street_ID); ViewBag.UserID = new SelectList(db.USER, "ID", "Email", property.UserID); ViewBag.Sale_ID = new SelectList(db.USER, "ID", "Email", property.Sale_ID); ViewBag.Ward_ID = new SelectList(db.WARD, "ID", "WardName", property.Ward_ID); return(View(property)); } else { return(RedirectToAction("Login", "Account", new { area = "" })); } }
public static void CleanDatabase(TestContext context) { using (var db = new DemoPPCRentalEntities()) { //db.OrderLines.RemoveRange(db.OrderLines); //db.Orders.RemoveRange(db.Orders); //db.Books.RemoveRange(db.Books); db.SaveChanges(); } }
public void CleanDatabase() { using (var db = new DemoPPCRentalEntities()) { //db.OrderLines.RemoveRange(db.OrderLines); //db.Orders.RemoveRange(db.Orders); db.PROPERTY.RemoveRange(db.PROPERTY); db.SaveChanges(); } }
public ActionResult Admin_ActivateAccount(int id, USER user) { using (DemoPPCRentalEntities entities = new DemoPPCRentalEntities()) { var EditedInfo = entities.USERs.FirstOrDefault(x => x.ID == id); EditedInfo.Status = true; //entities.Configuration.ValidateOnSaveEnabled = false; entities.SaveChanges(); } return(RedirectToAction("Admin_ControlPage")); }
public ActionResult ChangePassword(int id, USER user) { using (DemoPPCRentalEntities entities = new DemoPPCRentalEntities()) { var AccountDetails = entities.USERs.FirstOrDefault(x => x.ID == id); AccountDetails.Password = Crypto.Hash(user.Password); AccountDetails.ConfirmPassword = Crypto.Hash(user.ConfirmPassword); entities.Configuration.ValidateOnSaveEnabled = false; entities.SaveChanges(); return(Redirect(Url.Action("Agency_AccountPage", "Agency") + "/" + Session["ID"])); } }
public long InsertProperty(PROPERTy entity) { if (entity.ImageFile == null) { entity.Images = "ImagesNull.png"; } if (entity.ImageFile2 == null) { entity.Avatar = "AvatarNull.png"; } if (entity.District_ID == null) { entity.District_ID = null; } if (entity.Status_ID == null) { entity.District_ID = null; } db.PROPERTies.Add(entity); db.SaveChanges(); return(entity.ID); }
public ActionResult Admin_Decentralization(int id, USER user) { using (DemoPPCRentalEntities entities = new DemoPPCRentalEntities()) { var EditedInfo = entities.USERs.FirstOrDefault(x => x.ID == id); EditedInfo.Email = user.Email; EditedInfo.Password = user.Password; EditedInfo.FullName = user.FullName; EditedInfo.Phone = user.Phone; EditedInfo.Address = user.Address; EditedInfo.Role = user.Role; EditedInfo.Status = user.Status; entities.Configuration.ValidateOnSaveEnabled = false; entities.SaveChanges(); } return(RedirectToAction("Admin_ControlPage")); }
public ActionResult Agency_UpdateInfomation(int id, USER user) { using (DemoPPCRentalEntities entities = new DemoPPCRentalEntities()) { var EditedInfo = entities.USERs.FirstOrDefault(x => x.ID == id); EditedInfo.Email = user.Email; EditedInfo.Password = user.Password; EditedInfo.ConfirmPassword = user.ConfirmPassword; EditedInfo.FullName = user.FullName; EditedInfo.Phone = user.Phone; EditedInfo.Address = user.Address; EditedInfo.Role = user.Role; EditedInfo.Status = user.Status; entities.Configuration.ValidateOnSaveEnabled = false; entities.SaveChanges(); } return(Redirect(Url.Action("Agency_AccountPage", "Agency") + "/" + Session["ID"])); }
public ActionResult Register(USER user) { using (DemoPPCRentalEntities entities = new DemoPPCRentalEntities()) { if (entities.USERs.Any(x => x.Email == user.Email)) { ViewBag.DuplicateMessage = "This Email has already used."; return(View("Register", user)); } user.Password = Crypto.Hash(user.Password); user.ConfirmPassword = Crypto.Hash(user.ConfirmPassword); entities.USERs.Add(user); entities.SaveChanges(); } ModelState.Clear(); ViewBag.SuccessMessage = "Your account successfully registered. Your account will be activated in 24h if all information is valid."; return(View("Register", new USER())); }
public ActionResult Sale_EditProject(int id, PROPERTY p) { var EditedInfo = entities.PROPERTies.FirstOrDefault(x => x.ID == id); EditedInfo.Avatar = p.Avatar; EditedInfo.Images = p.Images; EditedInfo.PropertyName = p.PropertyName; EditedInfo.PropertyType_ID = p.PropertyType_ID; EditedInfo.Area = p.Area; EditedInfo.BedRoom = p.BedRoom; EditedInfo.BathRoom = p.BathRoom; EditedInfo.PackingPlace = p.PackingPlace; EditedInfo.DISTRICT = p.DISTRICT; EditedInfo.WARD = p.WARD; EditedInfo.STREET = p.STREET; EditedInfo.Content = p.Content; EditedInfo.Status_ID = p.Status_ID; EditedInfo.Note = p.Note; entities.SaveChanges(); return(RedirectToAction("Sale_ProjectsList")); }
public ActionResult PostProject(PROPERTY p) { var Ei = new PROPERTY(); Ei.Avatar = p.Avatar; Ei.Images = p.Images; Ei.PropertyName = p.PropertyName; Ei.PropertyType_ID = p.PropertyType_ID; Ei.Area = p.Area; Ei.BedRoom = p.BedRoom; Ei.BathRoom = p.BathRoom; Ei.PackingPlace = p.PackingPlace; Ei.District_ID = p.District_ID; Ei.Ward_ID = p.Ward_ID; Ei.Street_ID = p.Street_ID; Ei.Content = p.Content; Ei.Status_ID = p.Status_ID; Ei.Note = p.Note; entities.PROPERTies.Add(Ei); entities.SaveChanges(); return(RedirectToAction("Sale_ProjectsList")); }
public void InsertToDb(Table us) { using (db) { foreach (var row in us.Rows) { var user = new USER { Email = row["Email"], Password = row["Password"], FullName = row["FullName"], Phone = row["Phone"], Address = row["Address"], Role = int.Parse(row["Role"]), Status = true, }; _context.ReferenceUsers.Add(us.Header.Contains("ID") ? row["ID"] : user.Email, user); db.USER.Add(user); } db.SaveChanges(); } }
public ActionResult EditStatus(PROPERTY p) { PROPERTY project = new PROPERTY(); string s; string b; AvatarU(p, out project, out s); ImagesU(p, out project, out b); if (ModelState.IsValid) { project.Status_ID = p.Status_ID; project.Note = p.Note; project.PropertyName = p.PropertyName; project.Avatar = s; project.Images = b; project.PropertyType_ID = p.PropertyType_ID; project.Content = p.Content; project.Street_ID = p.Street_ID; project.Ward_ID = p.Ward_ID; project.District_ID = p.District_ID; project.Price = p.Price; project.UnitPrice = "VND"; project.Area = p.Area; project.BedRoom = p.BedRoom; project.BathRoom = p.BathRoom; project.PackingPlace = p.PackingPlace; db.Entry(project).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ViewListofAgencyProject", "ProjectAdmin")); } ViewBag.PropertyType_ID = new SelectList(db.PROPERTY_TYPE, "ID", "CodeType"); ViewBag.Ward_ID = new SelectList(db.WARD.Where(y => y.ID >= 31 && y.ID <= 54), "ID", "WardName"); ViewBag.District_ID = new SelectList(db.DISTRICT.Where(y => y.ID >= 31 && y.ID <= 54), "ID", "DistrictName"); ViewBag.Street_ID = new SelectList(db.STREET.Where(y => y.ID >= 31 && y.ID <= 54), "ID", "StreetName"); ViewBag.Status_ID = db.PROJECT_STATUS.OrderByDescending(x => x.ID).ToList(); return(View(p)); }
//public Contact GetActiveContact() //{ // return db.Contacts.Single(x => x.Status == true); //} public long InsertFeedBack(Contact fb) { db.Contacts.Add(fb); db.SaveChanges(); return(fb.ID); }
public long Insert(USER entity) { db.USER.Add(entity); db.SaveChanges(); return(entity.ID); }