Ejemplo n.º 1
0
        public ActionResult EditProfile(int id, TblChampionship 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 EditChampionshipList = db.Championship_tbl.Where(x => x.ChampionshipId == id && x.Status == 1).FirstOrDefault();

            if (EditChampionshipList != null)
            {
                EditChampionshipList.Championship          = model.Championship;
                EditChampionshipList.Category              = model.Category;
                EditChampionshipList.ChampionshipStartDate = model.ChampionshipStartDate;
                EditChampionshipList.ChampionshipEndDate   = model.ChampionshipEndDate;

                if (bytes != null)
                {
                    EditChampionshipList.Image = bytes;
                }
                db.SaveChanges();
            }
            //db.Entry(model).State = System.Data.Entity.EntityState.Modified;
            //db.SaveChanges();

            return(Content("<script>alert('Updated Successfully');location.href='ChampionshipView';</script>"));
        }
Ejemplo n.º 2
0
        public ActionResult ChampionshipRegistration(TblChampionship model, string Category, string city, HttpPostedFileBase postedFile)
        {
            var userid = Session["UserId"].ToString();
            var championshipsponsorid = Session["ChampionshipSponsorId"].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.Championship_tbl.Add(new TblChampionship
                {
                    ChampionshipReferenceNumber = "1",
                    Championship          = model.Championship,
                    Category              = model.Category,
                    ChampionshipStartDate = model.ChampionshipStartDate,
                    ChampionshipEndDate   = model.ChampionshipEndDate,
                    CityId                = Convert.ToInt32(city),
                    Image                 = bytes,
                    SponsorId             = 1,
                    ChampionshipSponsorId = Convert.ToInt32(championshipsponsorid),
                    Status                = 1,
                    CreatedId             = 1,
                    CreatedDate           = DateTime.Now,
                    ModifiedId            = 0,
                    ModifiedDate          = DateTime.Now
                });

                db.SaveChanges();

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