Beispiel #1
0
 public ActionResult edit(int id, editModel model)
 {
     if (this.ModelState.IsValid)
     {
         var editUser = db.Users.FirstOrDefault(p => p.ID == id);
         editUser.Realname = model.Realname;
         editUser.Usertype = model.Usertype;
         db.SaveChanges();
     }
     else
     {
         return(RedirectToAction("edit", new { id = id }));
     }
     return(RedirectToAction("index"));
 }
Beispiel #2
0
        public ActionResult edit(int id)
        {
            var editUser = db.Users.FirstOrDefault(p => p.ID == id);

            if (editUser == null)
            {
                return(RedirectToAction("Index"));
            }
            editModel user = new editModel();

            user.Username = editUser.Username;
            user.Realname = editUser.Realname;
            user.Usertype = editUser.Usertype;
            bindUserType();
            return(View(user));
        }
        public ActionResult Edit(int id)
        {
            string userid = Convert.ToString(Session["UserID"]);

            if (string.IsNullOrEmpty(userid))
            {
                return(RedirectToAction("login"));
            }
            //var ab = db.properties.Where(x => x.PropID == id).FirstOrDefault();
            //IEnumerable<newPropModal> proper = (from r in db.properties
            //                                    where r.PropID == id
            //                                    select new newPropModal
            //                                    {
            //                                        ProID = id,
            //                                        propName = r.pName,
            //                                        PropFor = r.propFor,
            //                                        ProType = r.pType,
            //                                        Price = r.pPrice,
            //                                        nooffloor = r.pFloors,
            //                                        noofBed = r.pNoofBeds,
            //                                        SizeSquare = r.pSizeSquare,
            //                                        CityID = r.pCityID_FK,
            //                                        Address = r.pAddress,
            //                                        description = r.pDescription,
            //                                    });
            var resl = from empl in db.properties.AsEnumerable() where empl.PropID == id select empl;

            ViewBag.Proper = resl;
            //DataTable dt_leaddata = new DataTable();
            //dt_leaddata = LeadClass.GetleadDataByGuid(id);
            //var list = dt_leaddata.AsEnumerable().ToList();
            //ViewBag.leaddata = list[0];
            //var query = from empl in db.properties.AsEnumerable() select empl;
            //List<property> dt = query.ToList();

            Int32? cityid = 1;
            Int32? floor  = 1;
            Int32? beds   = 1;
            Int32? roomm  = 1;
            Int32? ptype  = 1;
            string pfor   = "";

            foreach (var t in resl)
            {
                cityid = t.pCityID_FK;
                floor  = t.pFloors;
                beds   = t.pNoofBeds;
                ptype  = t.pType;
                pfor   = t.propFor;
            }

            List <SelectListItem> pType = new List <SelectListItem>();

            pType.Add(new SelectListItem()
            {
                Text = "Villa", Value = "1"
            });
            pType.Add(new SelectListItem()
            {
                Text = "Student Apartment", Value = "2"
            });
            pType.Add(new SelectListItem()
            {
                Text = "Family Apartment", Value = "3"
            });
            this.ViewBag.pType = new SelectList(pType, "Value", "Text", ptype);

            List <SelectListItem> pFor = new List <SelectListItem>();

            pFor.Add(new SelectListItem()
            {
                Text = "Rent", Value = "Rent"
            });
            pFor.Add(new SelectListItem()
            {
                Text = "Sale", Value = "Sale"
            });
            this.ViewBag.pFor = new SelectList(pFor, "Value", "Text", pfor);

            List <SelectListItem> bedd = new List <SelectListItem>();

            bedd.Add(new SelectListItem()
            {
                Text = "1", Value = "1"
            });
            bedd.Add(new SelectListItem()
            {
                Text = "2", Value = "2"
            });
            bedd.Add(new SelectListItem()
            {
                Text = "3", Value = "3"
            });
            bedd.Add(new SelectListItem()
            {
                Text = "4", Value = "4"
            });
            bedd.Add(new SelectListItem()
            {
                Text = "5", Value = "5"
            });
            bedd.Add(new SelectListItem()
            {
                Text = "6", Value = "6"
            });
            bedd.Add(new SelectListItem()
            {
                Text = "7+", Value = "7"
            });
            this.ViewBag.beds = new SelectList(bedd, "Value", "Text", beds);

            List <SelectListItem> rooms = new List <SelectListItem>();

            rooms.Add(new SelectListItem()
            {
                Text = "1", Value = "1"
            });
            rooms.Add(new SelectListItem()
            {
                Text = "2", Value = "2"
            });
            rooms.Add(new SelectListItem()
            {
                Text = "3", Value = "3"
            });
            rooms.Add(new SelectListItem()
            {
                Text = "4", Value = "4"
            });
            rooms.Add(new SelectListItem()
            {
                Text = "5", Value = "5"
            });
            rooms.Add(new SelectListItem()
            {
                Text = "6", Value = "6"
            });
            rooms.Add(new SelectListItem()
            {
                Text = "7+", Value = "7"
            });
            this.ViewBag.rooms = new SelectList(rooms, "Value", "Text", roomm);

            List <SelectListItem> floors = new List <SelectListItem>();

            floors.Add(new SelectListItem()
            {
                Text = "1", Value = "1"
            });
            floors.Add(new SelectListItem()
            {
                Text = "2", Value = "2"
            });
            floors.Add(new SelectListItem()
            {
                Text = "3", Value = "3"
            });
            floors.Add(new SelectListItem()
            {
                Text = "4", Value = "4"
            });
            floors.Add(new SelectListItem()
            {
                Text = "5", Value = "5"
            });
            floors.Add(new SelectListItem()
            {
                Text = "6", Value = "6"
            });
            floors.Add(new SelectListItem()
            {
                Text = "7+", Value = "7"
            });
            this.ViewBag.floors = new SelectList(floors, "Value", "Text", floor);
            var citiesb = db.cities;

            ViewBag.Cities = new SelectList(citiesb, "cityID", "cityName", cityid);
            editModel mod = new editModel();

            //ViewBag.Proper = dt;
            return(View(mod));
        }
        public ActionResult Edit(FormCollection form, HttpPostedFileBase[] imagProp, editModel modal)
        {
            int id = Convert.ToInt16(form["propid"]);

            //int id = modal.ProID;
            if (ModelState.IsValid)
            {
                if (HttpContext.Session["UserID"] == "" || HttpContext.Session["UserID"] == null)
                {
                    return(RedirectToAction("login"));
                }
                property result = (from p in db.properties
                                   where p.PropID == id
                                   select p).SingleOrDefault();

                result.pName          = modal.propName;
                result.pPrice         = modal.Price;
                result.pType          = modal.ProType;
                result.propFor        = modal.PropFor;
                result.pFloors        = modal.nooffloor;
                result.pNoofRooms     = modal.noofrooms;
                result.pNoofBeds      = modal.noofBed;
                result.pSizeSquare    = modal.SizeSquare;
                result.pCityID_FK     = modal.CityID;
                result.pAddress       = modal.Address;
                result.pPostCode      = Convert.ToString(modal.Postcode);
                result.pAvailableFrom = Convert.ToDateTime(modal.availablefrom);
                result.pDescription   = modal.description;
                //db.Entry(result).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                propImage image = db.propImages.Create();
                foreach (HttpPostedFileBase file in imagProp)
                {
                    if (file != null)
                    {
                        if (imagProp.Count() >= 1)
                        {
                            System.IO.Stream fullstream;
                            fullstream = file.InputStream;
                            byte[] fullimage = dal.ResizeUplImage(fullstream);


                            System.IO.Stream MyStream;
                            MyStream = file.InputStream;
                            byte[] newimage = dal.ResizeUploadedImage(MyStream);
                            image.propImageThumb = newimage;


                            image.propID_FK      = id;
                            image.propImage1     = fullimage;
                            image.propAgentID_FK = Convert.ToInt32(HttpContext.Session["UserID"]);
                            db.propImages.Add(image);
                            db.SaveChanges();
                        }
                    }
                }
                ViewBag.Message = "Property Updated successfully";
                ModelState.Clear();
            }
            var resl = from empl in db.properties.AsEnumerable() where empl.PropID == id select empl;

            ViewBag.Proper = resl;

            Int32? cityid = 1;
            Int32? floor  = 1;
            Int32? beds   = 1;
            Int32? roomm  = 1;
            Int32? ptype  = 1;
            string pfor   = "";

            foreach (var t in resl)
            {
                cityid = t.pCityID_FK;
                floor  = t.pFloors;
                beds   = t.pNoofBeds;
                ptype  = t.pType;
                pfor   = t.propFor;
            }

            List <SelectListItem> pType = new List <SelectListItem>();

            pType.Add(new SelectListItem()
            {
                Text = "Villa", Value = "1"
            });
            pType.Add(new SelectListItem()
            {
                Text = "Student Apartment", Value = "2"
            });
            pType.Add(new SelectListItem()
            {
                Text = "Family Apartment", Value = "3"
            });
            this.ViewBag.pType = new SelectList(pType, "Value", "Text", ptype);

            List <SelectListItem> pFor = new List <SelectListItem>();

            pFor.Add(new SelectListItem()
            {
                Text = "Rent", Value = "Rent"
            });
            pFor.Add(new SelectListItem()
            {
                Text = "Sale", Value = "Sale"
            });
            this.ViewBag.pFor = new SelectList(pFor, "Value", "Text", pfor);

            List <SelectListItem> bedd = new List <SelectListItem>();

            bedd.Add(new SelectListItem()
            {
                Text = "1", Value = "1"
            });
            bedd.Add(new SelectListItem()
            {
                Text = "2", Value = "2"
            });
            bedd.Add(new SelectListItem()
            {
                Text = "3", Value = "3"
            });
            bedd.Add(new SelectListItem()
            {
                Text = "4", Value = "4"
            });
            bedd.Add(new SelectListItem()
            {
                Text = "5", Value = "5"
            });
            bedd.Add(new SelectListItem()
            {
                Text = "6", Value = "6"
            });
            bedd.Add(new SelectListItem()
            {
                Text = "7+", Value = "7"
            });
            this.ViewBag.beds = new SelectList(bedd, "Value", "Text", beds);

            List <SelectListItem> rooms = new List <SelectListItem>();

            rooms.Add(new SelectListItem()
            {
                Text = "1", Value = "1"
            });
            rooms.Add(new SelectListItem()
            {
                Text = "2", Value = "2"
            });
            rooms.Add(new SelectListItem()
            {
                Text = "3", Value = "3"
            });
            rooms.Add(new SelectListItem()
            {
                Text = "4", Value = "4"
            });
            rooms.Add(new SelectListItem()
            {
                Text = "5", Value = "5"
            });
            rooms.Add(new SelectListItem()
            {
                Text = "6", Value = "6"
            });
            rooms.Add(new SelectListItem()
            {
                Text = "7+", Value = "7"
            });
            this.ViewBag.rooms = new SelectList(rooms, "Value", "Text", roomm);

            List <SelectListItem> floors = new List <SelectListItem>();

            floors.Add(new SelectListItem()
            {
                Text = "1", Value = "1"
            });
            floors.Add(new SelectListItem()
            {
                Text = "2", Value = "2"
            });
            floors.Add(new SelectListItem()
            {
                Text = "3", Value = "3"
            });
            floors.Add(new SelectListItem()
            {
                Text = "4", Value = "4"
            });
            floors.Add(new SelectListItem()
            {
                Text = "5", Value = "5"
            });
            floors.Add(new SelectListItem()
            {
                Text = "6", Value = "6"
            });
            floors.Add(new SelectListItem()
            {
                Text = "7+", Value = "7"
            });
            this.ViewBag.floors = new SelectList(floors, "Value", "Text", floor);

            var citiesb = db.cities;

            ViewBag.Cities = new SelectList(citiesb, "cityID", "cityName");

            return(View(modal));
        }