Exemple #1
0
        public ActionResult ApplymembershipForm(MemberShip mem)
        {
            try
            {
                if (mem != null)
                {
                    string              Registrationno = " start";
                    List <MemberShip>   list1          = db.MemberShips.ToList();
                    List <Registration> list           = db.Registrations.ToList();
                    var usermail = (string)Session["Email"];

                    foreach (Registration reg in list)
                    {
                        if (reg.Email == usermail)
                        {
                            Registrationno = reg.RegistrationNumber;
                            if (list1.Count == 0)
                            {
                                mem.RegistrationNumber = reg.RegistrationNumber;
                                mem.status             = false;
                                db.MemberShips.Add(mem);
                                db.SaveChanges();
                                ModelState.Clear();
                            }
                            else
                            {
                                var Exist = db.MemberShips.Where(x => x.RegistrationNumber == Registrationno).SingleOrDefault();

                                if (Exist == null)
                                {
                                    mem.RegistrationNumber = reg.RegistrationNumber; mem.status = false;
                                    db.MemberShips.Add(mem);
                                    db.SaveChanges();
                                    ModelState.Clear();
                                }
                                else
                                {
                                    ViewBag.message = "You are already applied for membership";
                                }
                            }
                        }
                    }
                }

                else
                {
                    ViewBag.message = "Please Fill this form";
                    return(View());
                }
            }
            catch (Exception ex)
            {
                return(View());
            }
            ViewBag.Uppermessage = "Your request has been sent successfully";
            return(View());
        }
 public ActionResult Edit(int id, upload_image img)
 {
     try
     {
         if (img.ImageFile != null)
         {
             string fileName  = Path.GetFileNameWithoutExtension(img.ImageFile.FileName);
             string extension = Path.GetExtension(img.ImageFile.FileName);
             fileName     = fileName + DateTime.Now.ToString("yymmssfff") + extension;
             img.img_path = "~/User-Images/" + fileName;
             fileName     = Path.Combine(Server.MapPath("~/User-Images/"), fileName);
             img.ImageFile.SaveAs(fileName);
         }
         using (SocietyofACEntities1 db = new SocietyofACEntities1())
         {
             db.Entry(img).State = EntityState.Modified;
             db.SaveChanges();
         }
         return(RedirectToAction("Events"));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult AddEvents(upload_image imageModel)
        {
            try
            {
                if (imageModel.ImageFile != null)
                {
                    string fileName  = Path.GetFileNameWithoutExtension(imageModel.ImageFile.FileName);
                    string extension = Path.GetExtension(imageModel.ImageFile.FileName);
                    fileName            = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                    imageModel.img_path = "~/User-Images/" + fileName;
                    fileName            = Path.Combine(Server.MapPath("~/User-Images/"), fileName);
                    imageModel.ImageFile.SaveAs(fileName);
                }
                using (SocietyofACEntities1 db = new SocietyofACEntities1())
                {
                    db.upload_image.Add(imageModel);
                    db.SaveChanges();
                }
                ModelState.Clear();
                return(View());
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult Edit(string Email, Registration reg, HttpPostedFileBase postedFile)
        {
            try
            {
                // TODO: Add update logic here
                if (postedFile != null)
                {
                    string filename   = Path.GetFileNameWithoutExtension(postedFile.FileName);
                    string Extenttion = Path.GetExtension(postedFile.FileName);
                    filename      = filename + DateTime.Now.ToString("yymmssfff") + Extenttion;
                    reg.Imagepath = "~/User-Images/" + filename;
                    filename      = Path.Combine(Server.MapPath("~/User-Images/"), filename);
                    postedFile.SaveAs(filename);
                }
                using (SocietyofACEntities1 db = new SocietyofACEntities1())
                {
                    db.Entry(reg).State = EntityState.Modified;
                    db.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Delete(int id, FormCollection collection)
        {
            try

            {
                using (SocietyofACEntities1 db = new SocietyofACEntities1())
                {
                    upload_image img = db.upload_image.Where(x => x.id == id).FirstOrDefault();
                    db.upload_image.Remove(img);
                    db.SaveChanges();
                }
                return(RedirectToAction("Events"));
            }


            catch
            {
                return(View());
            }
        }
Exemple #6
0
        public ActionResult Delete(string RegistrationNumber, FormCollection collection)
        {
            try

            {
                using (SocietyofACEntities1 db = new SocietyofACEntities1())
                {
                    Registration reg = db.Registrations.Where(x => x.RegistrationNumber == RegistrationNumber).FirstOrDefault();
                    db.Registrations.Remove(reg);
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }


            catch
            {
                return(View());
            }
        }
Exemple #7
0
 public ActionResult Index(UserClass US, HttpPostedFileBase postedFile)
 {
     try
     {
         bool check = true;
         List <Registration> list = db.Registrations.ToList();
         if (list != null)
         {
             foreach (Registration re in list)
             {
                 string R_N = re.RegistrationNumber.Trim();
                 if (R_N == US.RegistrationNumber)
                 {
                     check = false;
                 }
             }
         }
         if (check == true)
         {
             Registration reg = new Registration();
             reg.RegistrationNumber = US.RegistrationNumber.Trim();
             reg.Name             = US.Name.Trim();
             reg.Email            = US.Email.Trim();
             reg.Password         = US.Password.Trim();
             reg.Conform_Password = US.Conform_password.Trim();
             if (postedFile != null && postedFile.ContentLength > 0)
             {
                 string filename   = Path.GetFileNameWithoutExtension(postedFile.FileName);
                 string Extenttion = Path.GetExtension(postedFile.FileName);
                 filename     = filename + DateTime.Now.ToString("yymmssfff") + Extenttion;
                 US.ImagePath = "~/User-Images/" + filename;
                 filename     = Path.Combine(Server.MapPath("~/User-Images/"), filename);
                 postedFile.SaveAs(filename);
                 reg.Imagepath = US.ImagePath;
             }
             using (SocietyofACEntities1 db = new SocietyofACEntities1())
             {
                 db.Registrations.Add(reg);
                 db.SaveChanges();
             }
         }
         if (check == false)
         {
             ViewBag.message = "Registration number already exist.please enter another one.";
         }
         if (list == null)
         {
             Registration reg = new Registration();
             reg.RegistrationNumber = US.RegistrationNumber;
             reg.Name             = US.Name;
             reg.Email            = US.Email;
             reg.Password         = US.Password;
             reg.Conform_Password = US.Conform_password;
             if (postedFile != null && postedFile.ContentLength > 0)
             {
                 string filename   = Path.GetFileNameWithoutExtension(postedFile.FileName);
                 string Extenttion = Path.GetExtension(postedFile.FileName);
                 filename     = filename + DateTime.Now.ToString("yymmssfff") + Extenttion;
                 US.ImagePath = "~/User-Images/" + filename;
                 filename     = Path.Combine(Server.MapPath("~/User-Images/"), filename);
                 postedFile.SaveAs(filename);
                 reg.Imagepath = US.ImagePath;
             }
             using (SocietyofACEntities1 db = new SocietyofACEntities1())
             {
                 db.Registrations.Add(reg);
                 db.SaveChanges();
             }
         }
         ModelState.Clear();
     }
     catch (Exception ex)
     {
         return(View());
     }
     return(View());
 }