Example #1
0
        public ActionResult EditProfile(int id, TblPlayGround model, string city, HttpPostedFileBase postedFile)
        {
            List <TblCountry> countries = db.Country_tbl.ToList();

            ViewBag.CountryList = new SelectList(countries, "CountryId", "Country");

            if (postedFile != null)
            {
                using (BinaryReader br = new BinaryReader(postedFile.InputStream))
                {
                    bytes = br.ReadBytes(postedFile.ContentLength);
                }
            }
            var EditPlayGroundList = db.PlayGround_tbl.Where(x => x.PGId == id && x.Status == 1).FirstOrDefault();

            if (EditPlayGroundList != null)
            {
                EditPlayGroundList.Name         = model.Name;
                EditPlayGroundList.Length       = model.Length;
                EditPlayGroundList.Width        = model.Width;
                EditPlayGroundList.GoalLength   = model.GoalLength;
                EditPlayGroundList.GoalWidth    = model.GoalWidth;
                EditPlayGroundList.NoOfPlayer   = model.NoOfPlayer;
                EditPlayGroundList.Location     = model.Location;
                EditPlayGroundList.RentingPrice = model.RentingPrice;
                if (bytes != null)
                {
                    EditPlayGroundList.Image = bytes;
                }
                db.SaveChanges();
            }
            return(Content("<script>alert('Updated Successfully');location.href='PlayGroundView';</script>"));
        }
Example #2
0
        public ActionResult PlayGroundRegistration(TblPlayGround model, string city, HttpPostedFileBase postedFile)
        {
            var userid    = Session["UserId"].ToString();
            var pgownerid = Session["PGOwnerId"].ToString();
            List <TblCountry> countries = db.Country_tbl.ToList();

            ViewBag.CountryList = new SelectList(countries, "CountryId", "Country");

            List <TblUser> user = db.User_tbl.ToList();

            ViewBag.UserList = new SelectList(user, "UserId", "UserId");

            if (ModelState.IsValid)
            {
                byte[] bytes;
                using (BinaryReader br = new BinaryReader(postedFile.InputStream))
                {
                    bytes = br.ReadBytes(postedFile.ContentLength);
                }
                db.PlayGround_tbl.Add(new TblPlayGround
                {
                    PGReferenceNumber = "1",
                    PGOwnerId         = Convert.ToInt32(pgownerid),
                    Name             = model.Name,
                    Length           = model.Length,
                    Width            = model.Width,
                    GoalLength       = model.GoalLength,
                    GoalWidth        = model.GoalWidth,
                    NoOfPlayer       = model.NoOfPlayer,
                    CityId           = Convert.ToInt32(city),
                    Location         = model.Location,
                    Image            = bytes,
                    RentingPrice     = model.RentingPrice,
                    RegistrationDate = DateTime.Now,
                    ExpirationDate   = DateTime.Now.AddMonths(12),
                    Status           = 1,
                    CreatedId        = 1,
                    CreatedDate      = DateTime.Now,
                    ModifiedId       = 0,
                    ModifiedDate     = DateTime.Now
                });


                db.SaveChanges();



                return(RedirectToAction("PlayGround"));
            }
            return(View());
        }