public ActionResult Create([Bind(Include = "Id,Name,ContactNo,Designation,EmailId,CNIC,InstituteId,RequestStatusId,CreatedAt,Address,City,CompetitionId")] CompetitionRegistration competitionRegistration) { try { if (ModelState.IsValid) { try { if (competitionRegistration.CompetitionId == 2) { var teamLead = Request.Form["DramaTeamLeader"]; var totalMembers = Request.Form["DramaTotalTeamMembers"]; var dramaDescription = Request.Form["DramaDescription"]; var toSaveWithAddressString = " || " + teamLead + " || " + totalMembers + " || " + dramaDescription; competitionRegistration.Address = competitionRegistration.Address + " !Drama! " + toSaveWithAddressString; } competitionRegistration.RequestStatusId = 1; competitionRegistration.CreatedAt = DateTime.Now; db.CompetitionRegistrations.Add(competitionRegistration); db.SaveChanges(); string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); return(RedirectToAction("SubmissionResponce", "Home", new { status = "You are successfully registerd for Competition with your crdentials,Team SEE Lahore will soon respond you through Email.Stay Connected for Bigest Event of Lahore, See Lahore 2018", url = controllerName + "/" + actionName })); } catch (DbEntityValidationException ex) { string message = ""; foreach (var validationErrors in ex.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { message = message + validationError.PropertyName + " " + validationError.ErrorMessage + "\n\n"; } } HomeController.EntityinfoMessage(competitionRegistration.Name + ": " + message); HomeController.EntitywriteErrorLog(ex); string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); return(RedirectToAction("SubmissionResponce", "Home", new { status = "Due to Server overload something went wrong! please try again. Sorry for Inconvenience", url = controllerName + "/" + actionName })); } } ViewBag.CompetitionId = new SelectList(db.Competitions, "Id", "CompetitionName", competitionRegistration.CompetitionId); ViewBag.InstituteId = new SelectList(db.Institutes, "Id", "Institute1"); ViewBag.RequestStatusId = new SelectList(db.RequestStatus, "Id", "Status", competitionRegistration.RequestStatusId); return(View(competitionRegistration)); } catch (Exception ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); HomeController.infoMessage(ex.Message); HomeController.writeErrorLog(ex); return(RedirectToAction("SubmissionResponce", "Home", new { status = "Due to Server overload something went wrong! please try again. Sorry for Inconvenience", url = controllerName + "/" + actionName })); } }
public ActionResult Create([Bind(Include = "Id,Name,ContactNo,FacebookId,EmailId,CNIC,InstituteId,StatusId,CreatedAt,Address,CityOfResidence,Degree,PreviousExperiance,VolunteerCategoryId,Hostelite,Why,ExpectationsFromSEE")] Volunteer volunteer) { try { if (ModelState.IsValid) { var obj = db.Volunteers.FirstOrDefault(s => s.EmailId == volunteer.EmailId || s.ContactNo == volunteer.ContactNo); if (obj != null) { ViewBag.ErrorMessage = "Email Or Phone No. Already Exists!"; ViewBag.StatusId = new SelectList(db.RequestStatus, "Id", "Status", volunteer.StatusId); ViewBag.InstituteId = new SelectList(db.Institutes, "Id", "Institute1"); ViewBag.VolunteerCategoryId = new SelectList(db.VolunteerCategories, "Id", "Category", volunteer.VolunteerCategoryId); return(View(volunteer)); } try { volunteer.ExpectationsFromSEE = Request.Form["ExpectationsFromSEE"]; volunteer.CreatedAt = DateTime.Now; volunteer.StatusId = 1; db.Volunteers.Add(volunteer); db.SaveChanges(); string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); return(RedirectToAction("SubmissionResponce", "Home", new { status = "You are successfully registerd for volunteer with your crdentials,Team SEE Lahore will soon respond you through Email.Stay Connected for Bigest Event of Lahore,See Lahore 2018", url = controllerName + "/" + actionName })); } catch (DbEntityValidationException ex) { string message = ""; foreach (var validationErrors in ex.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { message = message + validationError.PropertyName + " " + validationError.ErrorMessage + "\n\n"; } } HomeController.EntityinfoMessage(volunteer.Name + ": " + message); HomeController.EntitywriteErrorLog(ex); string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); return(RedirectToAction("SubmissionResponce", "Home", new { status = "Due to Server overload something went wrong! please try again. Sorry for Inconvenience", url = controllerName + "/" + actionName })); } } ViewBag.StatusId = new SelectList(db.RequestStatus, "Id", "Status", volunteer.StatusId); ViewBag.InstituteId = new SelectList(db.Institutes, "Id", "Institute1"); ViewBag.VolunteerCategoryId = new SelectList(db.VolunteerCategories, "Id", "Category", volunteer.VolunteerCategoryId); return(View(volunteer)); } catch (Exception ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); HomeController.infoMessage(ex.Message); HomeController.writeErrorLog(ex); return(RedirectToAction("SubmissionResponce", "Home", new { status = "Due to Server overload something went wrong! please try again. Sorry for Inconvenience", url = controllerName + "/" + actionName })); } }
public ActionResult UpdateStatus(int?id, int?Status) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } try { Ambassador volunteer = db.Ambassadors.Find(id); if (volunteer == null) { return(HttpNotFound()); } volunteer.StatusId = Status; db.SaveChanges(); } catch (DbEntityValidationException ex) { string message = ""; foreach (var validationErrors in ex.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { message = message + validationError.PropertyName + " " + validationError.ErrorMessage + "\n\n"; } } HomeController.EntityinfoMessage("Ambassodor status: " + message); HomeController.EntitywriteErrorLog(ex); } } catch (Exception ex) { HomeController.infoMessage(ex.Message); HomeController.writeErrorLog(ex); } return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Id,Name,InstituteId,Degree,CGPA_Numbers,TotalNumbers,CNIC,ContactNo_,Email,CreatedAt,CurrentSemester_Year,RequestStatusId")] TalentGala talentGala) { try { if (ModelState.IsValid) { var obj = db.TalentGalas.FirstOrDefault(s => s.Email == talentGala.Email || s.ContactNo_ == talentGala.ContactNo_); if (obj != null) { ViewBag.ErrorMessage = "Email or Phone Number Already Exists!"; ViewBag.InstituteId = new SelectList(db.Institutes, "Id", "Institute1"); ViewBag.RequestStatusId = new SelectList(db.RequestStatus, "Id", "Status", talentGala.RequestStatusId); //ModelState.AddModelError("Error: ", "Email Already Exists!"); return(View(talentGala)); } if (Convert.ToDecimal(talentGala.TotalNumbers) == 4) { if (Convert.ToDecimal(talentGala.CGPA_Numbers) < 3) { ViewBag.ErrorMessage = "Your CGPA should be 3.0 atleast."; ViewBag.InstituteId = new SelectList(db.Institutes, "Id", "Institute1"); ViewBag.RequestStatusId = new SelectList(db.RequestStatus, "Id", "Status", talentGala.RequestStatusId); //ModelState.AddModelError("Error: ", "Your CGPA should be 3.0 atleast."); return(View(talentGala)); } if (Convert.ToDecimal(talentGala.CGPA_Numbers) > 4) { ViewBag.ErrorMessage = "Your CGPA can not be more than max."; ViewBag.InstituteId = new SelectList(db.Institutes, "Id", "Institute1"); ViewBag.RequestStatusId = new SelectList(db.RequestStatus, "Id", "Status", talentGala.RequestStatusId); //ModelState.AddModelError("Error: ", "Your CGPA should be 3.0 atleast."); return(View(talentGala)); } } else if (Convert.ToDecimal(talentGala.CGPA_Numbers) > Convert.ToDecimal(talentGala.TotalNumbers)) { ViewBag.ErrorMessage = "Total numbers should be greater then obtained marks"; ViewBag.InstituteId = new SelectList(db.Institutes, "Id", "Institute1"); ViewBag.RequestStatusId = new SelectList(db.RequestStatus, "Id", "Status", talentGala.RequestStatusId); //ModelState.AddModelError("Error: ", "Percentage of your marks should be 80% atleast."); return(View(talentGala)); } //else if (((Convert.ToDecimal(talentGala.CGPA_Numbers) / Convert.ToDecimal(talentGala.TotalNumbers)) * 100) < 80) //{ // ViewBag.ErrorMessage = "Percentage of your marks should be 80% atleast."; // ViewBag.InstituteId = new SelectList(db.Institutes, "Id", "Institute1"); // ViewBag.RequestStatusId = new SelectList(db.RequestStatus, "Id", "Status", talentGala.RequestStatusId); // //ModelState.AddModelError("Error: ", "Percentage of your marks should be 80% atleast."); // return View(talentGala); //} try { //var institute = Request.Form["InstituteId"]; talentGala.InstituteId =Convert.ToInt32(institute); talentGala.RequestStatusId = 1; talentGala.CreatedAt = DateTime.Now; db.TalentGalas.Add(talentGala); db.SaveChanges(); string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); return(RedirectToAction("SubmissionResponce", "Home", new { status = "You are successfully registerd for Talent Gala with your crdentials,Team SEE Lahore will soon respond you through Email.Stay Connected for Bigest Event of Lahore,See Lahore 2018", url = controllerName + "/" + actionName })); } catch (DbEntityValidationException ex) { string message = ""; foreach (var validationErrors in ex.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { message = message + validationError.PropertyName + " " + validationError.ErrorMessage + "\n\n"; } } HomeController.EntityinfoMessage(talentGala.Name + ": " + message); HomeController.EntitywriteErrorLog(ex); string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); return(RedirectToAction("SubmissionResponce", "Home", new { status = "Due to Server overload something went wrong! please try again. Sorry for Inconvenience", url = controllerName + "/" + actionName })); } } ViewBag.InstituteId = new SelectList(db.Institutes, "Id", "Institute1"); ViewBag.RequestStatusId = new SelectList(db.RequestStatus, "Id", "Status", talentGala.RequestStatusId); return(View(talentGala)); } catch (Exception ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); HomeController.infoMessage(ex.Message); HomeController.writeErrorLog(ex); return(RedirectToAction("SubmissionResponce", "Home", new { status = "Due to Server overload something went wrong! please try again. Sorry for Inconvenience", url = controllerName + "/" + actionName })); } }
public ActionResult Create([Bind(Include = "Id,StallName,StallDetails,Logo,RequestStatusId,CategoryId,CreatedBy,CreatedAt,OwnerName,ContactNo,Email,Address,City,Profession,Institute")] StallRequest stallRequest, HttpPostedFileBase Logo) { try { if (ModelState.IsValid) { var obj = db.StallRequests.FirstOrDefault(s => s.Email == stallRequest.Email); if (obj != null) { ViewBag.ErrorMessage = "Email Already Exists!"; ViewBag.CreatedBy = new SelectList(db.AspNetUsers, "Id", "Email", stallRequest.CreatedBy); ViewBag.InstituteId = new SelectList(db.Institutes, "Id", "Institute1"); ViewBag.RequestStatusId = new SelectList(db.RequestStatus, "Id", "Status", stallRequest.RequestStatusId); ViewBag.CategoryId = new SelectList(db.StallCategories, "Id", "StallType", stallRequest.CategoryId); return(View(stallRequest)); } if (Logo != null && Logo.ContentLength > 0) { var fileName = Path.GetFileName(Logo.FileName); var path = Path.Combine(Server.MapPath("~/UploadedImages/"), fileName); Logo.SaveAs(path); stallRequest.Logo = fileName; } try { stallRequest.RequestStatusId = 1; stallRequest.CreatedAt = DateTime.Now; stallRequest.CreatedBy = User.Identity.GetUserId(); db.StallRequests.Add(stallRequest); db.SaveChanges(); string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); return(RedirectToAction("SubmissionResponce", "Home", new { status = "Your stall proposal is successfully registerd with your crdentials,Team SEE Lahore will soon respond you through Email.Stay Connected for Bigest Event of Lahore,See Lahore 2018", url = controllerName + "/" + actionName })); } catch (DbEntityValidationException ex) { string message = ""; foreach (var validationErrors in ex.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { message = message + validationError.PropertyName + " " + validationError.ErrorMessage + "\n\n"; } } HomeController.EntityinfoMessage(stallRequest.OwnerName + ": " + message); HomeController.EntitywriteErrorLog(ex); string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); return(RedirectToAction("SubmissionResponce", "Home", new { status = "Due to Server overload something went wrong! please try again. Sorry for Inconvenience", url = controllerName + "/" + actionName })); } } ViewBag.CreatedBy = new SelectList(db.AspNetUsers, "Id", "Email", stallRequest.CreatedBy); ViewBag.InstituteId = new SelectList(db.Institutes, "Id", "Institute1"); ViewBag.RequestStatusId = new SelectList(db.RequestStatus, "Id", "Status", stallRequest.RequestStatusId); ViewBag.CategoryId = new SelectList(db.StallCategories, "Id", "StallType", stallRequest.CategoryId); return(View(stallRequest)); } catch (Exception ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); HomeController.infoMessage(ex.Message); HomeController.writeErrorLog(ex); return(RedirectToAction("SubmissionResponce", "Home", new { status = "Due to Server overload something went wrong! please try again. Sorry for Inconvenience", url = controllerName + "/" + actionName })); } }