// GET: Posts/Details/5 public async Task <IActionResult> Details(int?id, string name, Comment comment) { var myModel = new MultipleModel(); myModel.posts = _context.Post.ToList(); myModel.comments = _context.Comment.ToList(); if (name == null) { return(NotFound()); } var post = await _context.Post .FirstOrDefaultAsync(m => m.Title == name); if (post == null) { return(NotFound()); } ViewBag.Baslik = name; ViewBag.Date = post.Date.ToString().Substring(0, 10); ViewBag.Author = post.Author; ViewBag.Content = post.Content; ViewBag.Numara = post.Id; return(View(myModel)); }
// publicUI: publicUI'a girilirken login kontrolü yapılıyor daha sonra çalışanların publicUI'da gözükmesi için çalışan listesi modele aktarılıyor. public IActionResult Index() { MultipleModel mm = new MultipleModel(); mm.admin = HttpContext.Session.GetObjectFromJson <Admin>("adminInfos"); IAdminDal adminDal = new SqlServer(context); var result = adminDal.isLoginValid(mm); if (result.admin == null) { MultipleModel emptyMM = new MultipleModel(); emptyMM.admin.nick = "empty"; employeeDal.getAllEmployee(emptyMM); return(View(emptyMM)); } else { employeeDal.getAllEmployee(mm); return(View(mm)); } }
public async Task <IActionResult> MultipleUpload(MultipleModel md, IList <IFormFile> files) { if (ModelState.IsValid) { _context.Add(md.gallery); _context.SaveChanges(); foreach (var file in files) { GaleryImage img = new GaleryImage(); if (file.Length > 0) { using (var stream = new MemoryStream()) { await file.CopyToAsync(stream); img.Image = stream.ToArray(); img.Tag = string.Empty; img.GalleryID = md.gallery.GalleryID; } } _context.GaleryImages.Add(img); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(MultipleUpload))); } return(View()); }
public void fillDropdowns(MultipleModel mm) { // adminUI'daki dropdownların temizlenip listeye aktarılması ve daha sonra modele aktarılması. mm.Departments = Repeat.departmentRepeat(context.Departments.ToList()); mm.Managers = context.Managers.ToList(); mm.Employees = Repeat.employeeRepeat(context.Employees.ToList()); mm.Contacts = context.Contacts.ToList(); }
public void getAllEmployee(MultipleModel mm) { // publicUI'daki çalışanların listeye aktarılması ve daha sonra modele aktarılması. mm.Employees = context.Employees.ToList(); mm.Contacts = context.Contacts.ToList(); mm.Departments = context.Departments.ToList(); mm.Managers = context.Managers.ToList(); }
public ActionResult CreateGroup(MultipleModel.CreateGradeVM vm) { if (ModelState.IsValid) { using (var db = new LibraryDbContext()) { if (db.Grades.Where(u => u.Grade == vm.CreateGrade.Grade).Any()) { vm.Error = true; var errorList = new List<string>(); string message = "Grade " + vm.CreateGrade.Grade + " is already existing"; errorList.Add(message); vm.Message = errorList; TempData["AddGroup"] = vm; return RedirectToAction("GradesIndex", "Admin"); } else { var newGroup = db.Grades.Create(); newGroup.Grade = vm.CreateGrade.Grade; newGroup.CreatedAt = DateTime.Now; if (Request.Files.Count > 0) { var img = Request.Files[0]; if ((img != null) && (img.FileName == null)) { string name = Guid.NewGuid().ToString() + "_" + Path.GetFileName(img.FileName); string path = Path.Combine(Server.MapPath("~/Image/group_image"), name); img.SaveAs(path); var image = newGroup.Image; image.Name = name; image.Path = "~/Image/group_image/" + name; image.CreatedAt = DateTime.Now; } } db.Grades.Add(newGroup); db.SaveChanges(); vm.Error = false; var errorList = new List<string>(); string message = "You have successfully added a group(" + newGroup.Grade + ")"; errorList.Add(message); vm.Message = errorList; TempData["AddGroup"] = vm; return RedirectToAction("GradesIndex", "Admin"); } } } vm.Error = true; vm.Message = CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["AddGroup"] = vm; return RedirectToAction("GradesIndex", "Admin"); }
public ActionResult RegisterSeller(MultipleModel multipleModel) { int stateident = 0; int cityident = 0; try { //State stateId = null; //City cityId = null; Seller seller = new Seller(); User user = new User(); user.UserName = multipleModel.userModel.UserName; user.Pasword = multipleModel.userModel.Pasword; user.UserType = "Seller"; eHSContext.Users.Add(user); stateident = multipleModel.stateModel.StateId; cityident = multipleModel.cityModel.CityId; if (stateident != 0 && cityident != 0) { seller.UserName = multipleModel.userModel.UserName; seller.FirstName = multipleModel.sellerModel.FirstName; seller.LastName = multipleModel.sellerModel.LastName; seller.DateOfBirth = multipleModel.sellerModel.DateOfBirth; seller.PhoneNumber = multipleModel.sellerModel.PhoneNumber; seller.Adress = multipleModel.sellerModel.Adress; seller.EmailId = multipleModel.sellerModel.EmailId; seller.StateId = stateident; seller.CityId = cityident; eHSContext.Sellers.Add(seller); } eHSContext.SaveChanges(); ViewBag.Message = "Registered Successfully"; ModelState.Clear(); return(RedirectToAction("LoginUser", "Login")); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(View()); }
public ActionResult InsertGroupEntry(MultipleModel model) { try { Group_EntryBL gebl = new Group_EntryBL(); model.GroupModel.InsertOperator = Session["CompanyCD"].ToString(); Boolean insertFlag = false; if (model.GroupModel.SaveUpdateFlag == null) { model.GroupModel.SaveUpdateFlag = "Save"; DataTable dt = new DataTable(); dt = gebl.Check_Duplicate_GroupEntry(model); if (dt.Rows.Count > 0) { TempData["Imsg"] = "Duplicate"; } else { string PcName = System.Environment.MachineName; insertFlag = gebl.InsertGroupEntry(model, PcName); if (insertFlag) { TempData["Smsg"] = "success"; } else { TempData["Emsg"] = "Unsuccess"; } } } else { string PcName = System.Environment.MachineName; string a = model.GroupModel.SaveUpdateFlag; insertFlag = gebl.InsertGroupEntry(model, PcName); if (insertFlag) { TempData["USmsg"] = "success"; } else { TempData["UEmsg"] = "Unsuccess"; } } return(RedirectToAction("Group_Entry")); } catch (Exception ex) { string st = ex.ToString(); return(RedirectToAction("Group_Entry")); } }
public DataTable Check_Duplicate_GroupEntry(MultipleModel mModel) { BaseDL bdl = new BaseDL(); DataTable dtgroupID = new DataTable(); SqlParameter[] prms = new SqlParameter[1]; prms[0] = new SqlParameter("@groupID", SqlDbType.VarChar) { Value = mModel.GroupModel.GroupID }; dtgroupID = bdl.SelectData("M_Group_SelectBy_GroupID", prms); return(dtgroupID); }
public ActionResult Multiple(MultipleModel model) { if (model.Number == 0) { return(RedirectToAction("View1", new { number = model.Number }));//method, controller } if (model.Number < 0) { Response.Redirect("~/View2/" + model.Number); } ViewBag.rezult = model.Number * 10; return(View()); }
public ActionResult ActivateAccount(MultipleModel.LoginModelVM login) { if(ModelState.IsValid) { using (var db = new LibraryDbContext()) { var emailCheck = db.Users.Where(u => u.Email == login.ActivationModel.Email).ToList(); if(emailCheck[0] !=null) { var email = db.Users.SingleOrDefault(u => u.Email == login.ActivationModel.Email); var crypto = new PBKDF2(); if ((email.Password != null) && (email.PasswordSalt != null)) { login.Error = true; ModelState.AddModelError("", "The account is already activated"); return View("Login", login); } else if ((email != null) && (email.Pincode == crypto.Compute(login.ActivationModel.PinCode, email.PincodeSalt))) { var ctx = Request.GetOwinContext(); var authManager = ctx.Authentication; var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "acc_act"), new Claim(ClaimTypes.Role, "activation") }, "ApplicationCookie"); authManager.SignIn(identity); return RedirectToAction("ActivateAccount2", new { id = email.Id }); } else if ((email != null) && (email.Pincode != login.ActivationModel.PinCode)) { login.Error = true; ModelState.AddModelError("", "Incorrect pin entered"); return View("Login", login); } } else if (emailCheck[0] == null) { login.Error = true; ModelState.AddModelError("", "The account does not exist"); } } } login.Error = true; return View("Login", login); }
// kullanıcının hala online olup olmadığını kontrol eden metod. public MultipleModel isLoginValid(MultipleModel mm) { if (mm.admin != null) { MultipleModel admin1 = new MultipleModel(); admin1.admin.id = Convert.ToInt32(mm.admin.id); admin1.admin.nick = mm.admin.nick; admin1.admin.password = mm.admin.password; return(admin1); } else { return(mm); } }
public ActionResult TestMultipleData([CustomizeValidatorAttribute] MultipleModel info) { if (ModelState.IsValid) { return(RedirectToAction("Index")); } var errors = ModelState.Values.ToList().FindAll(item => item.Errors.Count > 0); var errorStrList = new List <string>(errors.Count); foreach (var item in errors) { errorStrList.Add(item.Errors.First().ErrorMessage); } return(Json(errorStrList, JsonRequestBehavior.AllowGet)); }
public ActionResult RegisterBuyer(MultipleModel multipleModel) { try { Buyer buyer = new Buyer(); User user = new User(); user.UserName = multipleModel.userModel.UserName; user.Pasword = multipleModel.userModel.Pasword; user.UserType = "Buyer"; eHSContext.Users.Add(user); buyer.UserName = multipleModel.userModel.UserName; buyer.FirstName = multipleModel.buyerModel.FirstName; buyer.LastName = multipleModel.buyerModel.LastName; buyer.DateOfBirth = multipleModel.buyerModel.DateOfBirth; buyer.PhoneNumber = multipleModel.buyerModel.PhoneNumber; buyer.EmailId = multipleModel.buyerModel.EmailId; eHSContext.Buyers.Add(buyer); eHSContext.SaveChanges(); ViewBag.Message = "Registered Successfully"; ModelState.Clear(); return(RedirectToAction("LoginUser", "Login")); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(View()); }
public ActionResult DisplayMovie() { IEnumerable <Movie> movie = movieBl.DisplayMovie(); MultipleModel displayMovie = new MultipleModel(); List <MovieModel> model = new List <MovieModel>(); List <SignUpNextModel> displayTheatre = new List <SignUpNextModel>(); foreach (var result in movie) { MovieModel movieModel = AutoMapper.Mapper.Map <Movie, MovieModel>(result); //using auto mapper model.Add(movieModel); Theatre theatre = theatreBl.DisplayTheatre(result.TheatreId); SignUpNextModel theatreModel = AutoMapper.Mapper.Map <Theatre, SignUpNextModel>(theatre); displayTheatre.Add(theatreModel); } displayMovie.Movies = model; displayMovie.Theatres = displayTheatre; return(View(displayMovie)); }
public ActionResult HomePage() { bool success = false; if (Session["uid"] != null) { int uid = Convert.ToInt32(Session["uid"].ToString()); UserDetailsAll ud = bl.GetUserDetails(uid, out success); MultipleModel m = new MultipleModel(); Group g = new Group(); m.UserDetails = ud; m.group = g; if (success == true) { bool success1 = false; string ImageUrl = bl.GetUserImage(uid, out success1); if (success1 == true) { ViewBag.ImageUrl = ImageUrl; } else { ViewBag.message = "Error occured while fetching image."; } if (TempData["message"] != null) { ViewBag.message = TempData["message"].ToString(); } return(View(m)); } else { ViewBag.message = "Error occured while fetching details. Please contact admin."; return(View()); } } else { return(RedirectToAction("Login")); } }
public ActionResult CreateCollege(MultipleModel.CollegeModelVM request) { var messageList = new List<string>(); if (ModelState.IsValid) { using (var db = new ElectionDbContext()) { if(db.Colleges.Where(c=>c.College == request.CreateCollege.CollegeName).Any()) { string message = request.CreateCollege.CollegeName + " is already existing!!"; messageList.Add(message); request.Message = messageList; request.Error = true; TempData["GroupsIndexTD"] = request; return RedirectToAction("GroupsIndex", "Admin"); } else if(!(db.Colleges.Where(c => c.College == request.CreateCollege.CollegeName).Any())) { var newCollege = db.Colleges.Create(); newCollege.College = request.CreateCollege.CollegeName; newCollege.CreatedAt = DateTime.Now; db.Colleges.Add(newCollege); db.SaveChanges(); request.Error = false; string message = "You have successfully added " + newCollege.College + ""; messageList.Add(message); request.Message = messageList; TempData["GroupsIndexTD"] = request.Error; TempData["GroupsIndexTD"] = request.Message; return RedirectToAction("GroupsIndex", "Admin"); } } } request.Error = true; request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["GroupsIndexTD"] = request; return RedirectToAction("GroupsIndex", "Admin"); }
// adminUI: adminUI'a girilirken login kontrolü yapılıyor daha sonra bu UI'daki ilgili dropdownlar dolduruluyor. public IActionResult Index() { MultipleModel mm = new MultipleModel(); mm.admin = HttpContext.Session.GetObjectFromJson <Admin>("adminInfos"); var result = adminDal.isLoginValid(mm); adminDal.fillDropdowns(mm); if (result.admin == null) { MultipleModel emptyMM = new MultipleModel(); emptyMM.admin.nick = "empty"; return(RedirectToAction("Index", "Home")); } else { return(View(mm)); } }
public ActionResult CreateGroup(MultipleModel model) { if (ModelState.IsValid) { bool success = false; var list = model.group.Memberlistid.Distinct(); string result = string.Join("", list).TrimEnd(','); model.group.Memberlistid = result; bl.CreateGroup(Session["uid"].ToString(), model.group, out success); if (success) { TempData["message"] = "Group created successfully"; } else { TempData["message"] = "Error occured while creating Group"; } } return(RedirectToAction("HomePage")); }
public ActionResult Login(MultipleModel.LoginModelVM user) { if (ModelState.IsValid) { using (var db = new LibraryDbContext()) { var crypto = new SimpleCrypto.PBKDF2(); var emailCheck = db.Users.FirstOrDefault(u => u.Email == user.AuthModel.Email); var getPasswordSalt = db.Users.Where(u => u.Email == user.AuthModel.Email).Select(u => u.PasswordSalt); if ((emailCheck != null) && (getPasswordSalt != null) && (emailCheck.Deleted == false) && (emailCheck.Status == true)) { var materializePasswordSalt = getPasswordSalt.ToList(); var passwordSalt = materializePasswordSalt[0]; var encryptedPassword = crypto.Compute(user.AuthModel.Password, passwordSalt); if (user.AuthModel.Email != null && emailCheck.Password == encryptedPassword) { var name = emailCheck.Student.FirstName; var getEmail = db.Users.Where(u => u.Id == emailCheck.Id).Select(u => u.Email); var materializeEmail = getEmail.ToList(); var email = materializeEmail[0]; var getRole = db.Users.Where(u => u.Id == emailCheck.Id).Select(u => u.Role); var materializeRole = getRole.ToList(); var role = materializeRole[0]; var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, name), new Claim(ClaimTypes.Email, email), new Claim(ClaimTypes.Role, role) }, "ApplicationCookie"); var ctx = Request.GetOwinContext(); var authManager = ctx.Authentication; authManager.SignIn(identity); if (emailCheck.Role == "administrator") { return RedirectToAction("GradesIndex", "Admin"); } else { return RedirectToAction("Index", "Auth"); } } else { user.Error = true; ModelState.AddModelError("", "Invalid email or password"); } } else if((emailCheck != null) && (emailCheck.Status == false) && (emailCheck.Deleted == false) ) { user.Error = true; ModelState.AddModelError("", "Please activate the account"); } else if(emailCheck == null || ((emailCheck.Deleted == true) && (emailCheck.Status == false))) { user.Error = true; ModelState.AddModelError("", "Account does not exist"); } } } user.Error = true; return View(user); }
public ActionResult CreateAccount(MultipleModel.StudentIndexModelVM request) { var messageList = new List<string>(); if(ModelState.IsValid) { using (var db = new ElectionDbContext()) { var getStudent = db.Students.SingleOrDefault(s=>s.Id == request.CreateUser.StudentId); if(getStudent != null) { if(!( (db.Users.Where(u => u.StudentId == getStudent.Id).Any()) && (db.Users.Where(u=>u.Email == request.CreateUser.Email).Any()) )) { string pin = SimpleCrypto.RandomPassword.Generate(6, SimpleCrypto.PasswordGroup.Lowercase, SimpleCrypto.PasswordGroup.Lowercase, SimpleCrypto.PasswordGroup.Numeric); var crypto = new SimpleCrypto.PBKDF2(); var encrypPin = crypto.Compute(pin); var newUser = db.Users.Create(); newUser.StudentId = request.CreateUser.StudentId; newUser.Email = request.CreateUser.Email; newUser.Role = request.CreateUser.Role; newUser.Pincode = encrypPin; newUser.PincodeSalt = crypto.Salt; newUser.CreatedAt = DateTime.Now; db.Users.Add(newUser); db.SaveChanges(); SMTP smtp = new SMTP(); smtp.SendEmal(newUser.Email, pin); request.Error = false; string message = "You have successfully created a user " + newUser.Email; messageList.Add(message); request.Message = messageList; TempData["StudentIndexTD"] = request; return RedirectToAction("StudentIndex", new { id = request.SectionId }); } else if ((db.Users.Where(u => u.StudentId == getStudent.Id).Any()) && (db.Users.Where(u => u.Email == request.CreateUser.Email).Any())) { request.Error = true; string message = "Failed to create a user. Email address or Student Id is already existing"; messageList.Add(message); request.Message = messageList; TempData["StudentIndexTD"] = request; return RedirectToAction("StudentIndex", new { id = request.SectionId }); } } else if (getStudent == null) { request.Error = true; string message = "Failed to create a user. The selected student does not exist"; messageList.Add(message); request.Message = messageList; TempData["StudentIndexTD"] = request; return RedirectToAction("StudentIndex", new { id = request.SectionId }); } } } request.Error = true; request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["StudentIndexTD"] = request; return RedirectToAction("StudentIndex", new { id = request.SectionId }); }
public ActionResult UpdateCollege(MultipleModel.CollegeModelVM request) { var messageList = new List<string>(); if (ModelState.IsValid) { using (var db = new ElectionDbContext()) { var colleges = db.Colleges.Find(request.UpdateCollege.CollegeId); if (colleges != null) { if(!(db.Colleges.Where(c=>c.College == request.UpdateCollege.CollegeName).Any())) { colleges.College = request.UpdateCollege.CollegeName; colleges.UpdatedAt = DateTime.Now; db.Entry(colleges).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); request.Error = false; string message = "You have successfully updated " + colleges.College; messageList.Add(message); request.Message = messageList; TempData["GroupsIndexTD"] = request.Error; TempData["GroupsIndexTD"] = request.Message; return RedirectToAction("GroupsIndex", "Admin"); } else if(db.Colleges.Where(c => c.College == request.UpdateCollege.CollegeName).Any()) { request.Error = true; string message = request.UpdateCollege.CollegeName+" is already existing!!"; messageList.Add(message); request.Message = messageList; TempData["GroupsIndexTD"] = request; return RedirectToAction("GroupsIndex", "Admin"); } } else if (colleges == null) { request.Error = true; string message = "The selected college does not exist!!"; messageList.Add(message); request.Message = messageList; TempData["GroupsIndexTD"] = request; return RedirectToAction("GroupsIndex", "Admin"); } } } request.Error = true; request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["GroupsIndexTD"] = request; return RedirectToAction("GroupsIndex", "Admin"); }
public ActionResult ActivateAccount2(MultipleModel.AuthModelVM request) { if(ModelState.IsValid) { using (var db = new LibraryDbContext()) { MultipleModel.AuthModelVM vm = new MultipleModel.AuthModelVM(); vm.UserModel = db.Users.SingleOrDefault(u => u.Id == request.UserModel.Id); var crypto = new SimpleCrypto.PBKDF2(); var encrypPass = crypto.Compute(request.ActivationModel1.Password); vm.UserModel.PasswordSalt = crypto.Salt; vm.UserModel.Password = encrypPass; vm.UserModel.SecretQuestion = request.ActivationModel1.SecretQuestion; vm.UserModel.SecretAnswer = request.ActivationModel1.SecretAnswer; vm.UserModel.Status = true; vm.UserModel.Deleted = false; vm.UserModel.UpdatedAt = DateTime.Now; vm.UserModel.Student.Birthday = request.ActivationModel1.Birthday; vm.UserAddressModel = db.UserAddresses.Create(); vm.UserAddressModel.UserId = vm.UserModel.Id; vm.UserAddressModel.ZipCode = request.ActivationModel1.ZipCode; vm.UserAddressModel.Address1 = request.ActivationModel1.Address1; vm.UserAddressModel.Address2 = request.ActivationModel1.Address2; vm.UserAddressModel.City = request.ActivationModel1.City; vm.UserAddressModel.Country = request.ActivationModel1.Country; vm.UserAddressModel.CreatedAt = DateTime.Now; db.UserAddresses.Add(vm.UserAddressModel); db.Entry(vm.UserModel).State = EntityState.Modified; db.SaveChanges(); var ctx = Request.GetOwinContext(); var authManager = ctx.Authentication; authManager.SignOut("ApplicationCookie"); var loginVM = new MultipleModel.LoginModelVM(); loginVM.Error = false; var errorList = new List<string>(); string message = "You have successfully activated your account. Please log in"; errorList.Add(message); loginVM.Message = errorList; TempData["LoginTD"] = loginVM; return RedirectToAction("Login"); } } request.Error = true; request.Message = CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["UserActivation"] = request; return RedirectToAction("ActivateAccount2", new { id = request.UserModel.Id }); }
public ActionResult Index(int?id, int?type) { cattype = type.GetValueOrDefault(); if (cattype != 0) { if (cattype == 2) { category = "G"; } else { category = "J"; } } else { GetCategory(); } Session["ExchangeRate"] = MatchBxCommon.GetExchangeRate(); TempData["TrendingTagsFooter"] = MatchBxCommon.GetTrendingTagsFooter(); MultipleModel modelMul = new MultipleModel(); int _loadmore = 0; JobCategoryId = id.GetValueOrDefault(); Session["JobCatId"] = JobCategoryId; dynamic model = new ExpandoObject(); objJob.JobCategoryId = JobCategoryId; objJob.FromPage = category; objJob.SortBy = "H"; if (Session["searchmodel"] != null && Session["FromDetails"] != null) { SearchCriteria _model = (SearchCriteria)Session["searchmodel"]; objJob.TrendingTagsIdList = _model.populartags; objJob.SkillsList = _model.topskills; ViewBag.budgetMin = _model.budgetMin; ViewBag.MaxBudget = _model.budgetMax; objJob.SortBy = _model.sortorder; Session["searchmodel"] = null; Session["FromDetails"] = null; } else { objJob.TrendingTagsIdList = "0"; objJob.SkillsList = "0"; } objJobList = MatchBxCommon.GenerateBadge(objJobMod.GetJobDetails(objJob).ToList().OrderByDescending(x => x.BudgetASP).ToList()); //objJobList = MatchBxCommon.GenerateBadge(objJobMod.GetJobDetails(objJob).ToList().OrderByDescending(x => x.BudgetASP).ThenByDescending(x => x.Rownumber).ToList()); TempData["JobList"] = objJobList; _TotalRecord = objJobList.Count(); if (_TotalRecord > _RecordDisplay) { _loadmore = 1; } else { _loadmore = 0; } objJobList.ForEach(s => s.Isloadmore = _loadmore); objJobList.ForEach(s => s.BudgetASPInt = Convert.ToInt32(s.BudgetASP)); model.Job = objJobList.Take(_RecordDisplay).ToList(); Session["Category"] = category; //if (category == "J") //{ // objJobList.ForEach(s => s.FromPage = "J"); // Session["Category"] = "J"; //} //else { // objJobList.ForEach(s => s.FromPage = "G"); // Session["Category"] = "G"; //} objTrending.JobCategoryId = JobCategoryId; objTrending.FromPage = category; objTrendingTagsList = objTrendingMod.GetTrendingTags(objTrending); model.TrendingTags = objTrendingTagsList; objTrendingTagsList.ForEach(s => s.Description = s.Description.Replace("#", "")); model.PopularTags = objTrendingTagsList; objSkills.JobCategoryId = JobCategoryId; Session["JobCategoryId"] = JobCategoryId; objSkills.FromPage = category; model.skills = objSkillsMod.GetTopSkills(objSkills); List <JobCategory> _JobcategoryList = new List <JobCategory>(); JobCategoryModel JobModel = new JobCategoryModel(); _JobcategoryList = JobModel.GetList(); Session["JobCategory"] = _JobcategoryList; model.messageSender = 0; if (Request.QueryString["mailMessagId"] != null) { string _messageSender = Request.QueryString["mailMessagId"].ToString(); model.messageSender = Convert.ToInt32(_messageSender); Session["mailMessagId"] = _messageSender; } return(View("Index", model)); }
public ActionResult DeleteStudent(MultipleModel.StudentIndexModelVM request) { var messageList = new List<string>(); if (ModelState.IsValid) { using (var db = new ElectionDbContext()) { var getStudent = db.Students.Find(request.DeleteStudent.StudentId); if (getStudent != null) { getStudent.Deleted = true; getStudent.UpdatedAt = DateTime.Now; db.Entry(getStudent).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); request.Error = false; string message = "You have successfully deleted student (" + getStudent.StudentNumber + ")"; messageList.Add(message); request.Message = messageList; TempData["StudentIndexTD"] = request; return RedirectToAction("StudentIndex", new { id = request.SectionId }); } else if (getStudent == null) { request.Error = true; string message = "The selected student does not exist!!"; messageList.Add(message); request.Message = messageList; TempData["StudentIndexTD"] = request; return RedirectToAction("StudentIndex", new { id = request.SectionId }); } } } request.Error = true; request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["StudentIndexTD"] = request; return RedirectToAction("StudentIndex", new { id = request.SectionId }); }
public ActionResult UpdateSection(MultipleModel.SectionModelVM request) { var messageList = new List<string>(); if (ModelState.IsValid) { using (var db = new ElectionDbContext()) { var section = db.Sections.Find(request.UpdateSection.SectionId); if (section != null) { if (!(db.Sections.Where(m => m.Section == request.UpdateSection.SectionName).Any())) { section.Section = request.UpdateSection.SectionName; section.UpdatedAt = DateTime.Now; db.Entry(section).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); request.Error = false; string message = "You have successfully updated " + section.Section; messageList.Add(message); request.Message = messageList; TempData["SectionIndexTD"] = request; return RedirectToAction("SectionIndex", new { id = request.MajorId }); } else if (db.Sections.Where(m => m.Section == request.UpdateSection.SectionName).Any()) { request.Error = true; string message = request.UpdateSection.SectionName + " is already existing!!"; messageList.Add(message); request.Message = messageList; TempData["SectionIndexTD"] = request; return RedirectToAction("SectionIndex", new { id = request.MajorId }); } } else if (section == null) { request.Error = true; string message = "The selected section does not exist!!"; messageList.Add(message); request.Message = messageList; TempData["SectionIndexTD"] = request; return RedirectToAction("SectionIndex", new { id = request.MajorId }); } } } request.Error = true; request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["SectionIndexTD"] = request; return RedirectToAction("SectionIndex", new { id = request.MajorId }); }
public Boolean InsertGroupEntry(MultipleModel mModel, string PcName) { try { DataTable dt = new DataTable(); BaseDL dl = new BaseDL(); SqlParameter[] prms = new SqlParameter[9]; prms[0] = new SqlParameter("@groupID", SqlDbType.VarChar) { Value = mModel.GroupModel.GroupID }; prms[1] = new SqlParameter("@groupName", SqlDbType.VarChar) { Value = mModel.GroupModel.GroupName }; prms[2] = new SqlParameter("@groupInfoFlag", SqlDbType.VarChar) { Value = mModel.GroupModel.GroupInfoFlg }; if (mModel.ComModel != null) { prms[3] = new SqlParameter("@companyName", SqlDbType.VarChar) { Value = mModel.ComModel.CompanyName }; } else { prms[3] = new SqlParameter("@companyName", SqlDbType.VarChar) { Value = DBNull.Value }; } if (mModel.MBrandModel != null) { prms[4] = new SqlParameter("@BrandName", SqlDbType.VarChar) { Value = mModel.MBrandModel.BrandName }; } else { prms[4] = new SqlParameter("@BrandName", SqlDbType.VarChar) { Value = DBNull.Value }; } if (mModel.tModel != null) { prms[5] = new SqlParameter("@tag", SqlDbType.VarChar) { Value = mModel.tModel.Tag }; } else { prms[5] = new SqlParameter("@tag", SqlDbType.VarChar) { Value = DBNull.Value }; } prms[6] = new SqlParameter("@AccessPC", SqlDbType.VarChar) { Value = PcName }; prms[7] = new SqlParameter("@insertOperator", SqlDbType.VarChar) { Value = mModel.GroupModel.InsertOperator }; prms[8] = new SqlParameter("@saveUpdateFlag", SqlDbType.VarChar) { Value = mModel.GroupModel.SaveUpdateFlag }; dl.InsertUpdateDeleteData("Group_Entry_Insert", prms); return(true); } catch (Exception ex) { string aa = ex.Message; return(false); } }
public ActionResult DeleteUser(MultipleModel.UserInformationVM vm) { var errorList = new List<string>(); string message = null; var user = db.Users.SingleOrDefault(u => u.Id == vm.User.Id); if (user != null) { user.Deleted = true; user.UpdatedAt = DateTime.Now; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); vm.Error = false; message = "You have successfully deleted " + user.Student.LastName + "'s account"; errorList.Add(message); vm.Message = errorList; TempData["UserInformationTD"] = vm; return RedirectToAction("UserIndex", new { id = user.Student.SectionId }); } vm.Error = true; message = "The selected user doesn't exist"; errorList.Add(message); vm.Message = errorList; TempData["UserInformationTD"] = vm; return RedirectToAction("UserInformation", new { id = vm.User.Id }); }
public ActionResult InsertCompany(MultipleModel model) { Company_EntryBL cbl = new Company_EntryBL(); TOSEntities _entity = new TOSEntities(); var CompanyCD = _entity.M_Company.Where(m => m.CompanyCD.Equals(model.ComModel.CompanyCD)).Select(s => s.CompanyCD).FirstOrDefault(); if (CompanyCD != null) { try { var option = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted, Timeout = TimeSpan.MaxValue }; TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option); using (scope) { string PcName = System.Environment.MachineName; //Update Company if (model.ComModel.ZipCD1 != null) { string[] zips = model.ComModel.ZipCD1.Split(new Char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); string zip1 = zips[0].ToString(); string zip2 = zips[1].ToString(); model.ComModel.ZipCD1 = zip1; model.ComModel.ZipCD2 = zip2; } model.ComModel.UpdateOperator = Session["CompanyCD"].ToString(); model.ComModel.UpdateDateTime = DateTime.Now; DataTable dt = cbl.UpdateCompany(model.ComModel, PcName); //Update Company Shipping DataTable dtshipping = new DataTable(); using (var reader = ObjectReader.Create(model.ShippingModel, "ShippingID", "ShippingName", "ZipCD1", "ZipCD2", "Address1", "Address2", "TelephoneNO", "FaxNO")) { dtshipping.Load(reader); } for (int k = 0; k < dtshipping.Rows.Count; k++) { string zipcd = dtshipping.Rows[k]["ZipCD1"].ToString(); if (!String.IsNullOrWhiteSpace(zipcd)) { if (zipcd.Contains("-")) { string[] zip = zipcd.Split('-'); dtshipping.Rows[k]["ZipCD1"] = zip[0]; dtshipping.Rows[k]["ZipCD2"] = zip[1]; } } } cbl.UpdateCompanyShipping(dtshipping, model.ComModel, PcName); //Update Company Tag DataTable dttag = new DataTable(); using (var reader = ObjectReader.Create(model.TagModel, "CompanyCD", "Tag")) { dttag.Load(reader); } cbl.UpdateCompanyTag(dttag, model.ComModel, PcName); //Update Company Brand if (model.MBrandModel.BrandName != null) { model.MBrandModel.UpdateOperator = Session["CompanyCD"].ToString(); cbl.UpdateCompanyBrand(model.MBrandModel, model.ComModel, PcName); } scope.Complete(); } TempData["Imsg"] = "success"; return(RedirectToAction("Company_Entry")); //return RedirectToAction("CompanyUpdate_View"); } catch (Exception ex) { string st = ex.ToString(); TempData["Emsg"] = "Unsuccess"; return(RedirectToAction("Company_Entry")); } } else { try { DataTable Checkdt = cbl.Check_Duplicate_CompanyCD(model.ComModel); if (Checkdt.Rows.Count > 0) { DataTable dtIMsg = cbl.Message_Select("1006", "I"); string message = string.Empty; if (dtIMsg.Rows.Count > 0) { // TempData["Imsg"] = dtIMsg.Rows[0]["Message1"].ToString(); TempData["Dmsg"] = "Duplicate CompanyCD is " + model.ComModel.CompanyCD; } } else { var option = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted, Timeout = TimeSpan.MaxValue }; TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option); using (scope) { string PcName = System.Environment.MachineName; //Insert Company if (model.ComModel.ZipCD1 != null) { string[] zips = model.ComModel.ZipCD1.Split(new Char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); string zip1 = zips[0].ToString(); string zip2 = zips[1].ToString(); model.ComModel.ZipCD1 = zip1; model.ComModel.ZipCD2 = zip2; } model.ComModel.InsertOperator = Session["CompanyCD"].ToString(); DataTable dt = cbl.InsertCompany(model.ComModel, PcName); //Insert Company Shipping Array arrayShip = model.ShippingModel.ToArray(); if (arrayShip.Length > 0) { for (int i = 0; i < arrayShip.Length; i++) { if ((!string.IsNullOrWhiteSpace(model.ShippingModel[i].ShippingID.ToString())) && (!string.IsNullOrWhiteSpace(model.ComModel.CompanyCD.ToString())) && model.ShippingModel[i].ShippingID.ToString() != "0") { if (model.ShippingModel[i].ZipCD1 != null) { string[] zipships = model.ShippingModel[i].ZipCD1.Split(new Char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); string zipShip1 = zipships[0].ToString(); string zipShip2 = zipships[1].ToString(); model.ShippingModel[i].ZipCD1 = zipShip1; model.ShippingModel[i].ZipCD2 = zipShip2; } model.ShippingModel[i].InsertOperator = Session["CompanyCD"].ToString(); DataTable dtShip = cbl.InsertCompanyShipping(model.ShippingModel[i], model.ComModel, PcName); } } } //Insert Company Tag Array ArrayTag = model.TagModel.ToArray(); if (ArrayTag.Length > 0) { for (int i = 0; i < ArrayTag.Length; i++) { if (model.TagModel[i].Tag != null && (!string.IsNullOrWhiteSpace(model.ComModel.CompanyCD.ToString()))) { model.TagModel[i].InsertOperator = Session["CompanyCD"].ToString(); DataTable dtTag = cbl.InsertCompanyTag(model.TagModel[i], model.ComModel, PcName); } } } //Insert Company Brand if (model.MBrandModel.BrandName != null) { model.MBrandModel.InsertOperator = Session["CompanyCD"].ToString(); DataTable dtBrand = cbl.InsertCompanyBrand(model.MBrandModel, model.ComModel, PcName); } scope.Complete(); } TempData["Imsg"] = "success"; } return(RedirectToAction("Company_Entry")); //return RedirectToAction("CompanyUpdate_View"); } catch (Exception ex) { string st = ex.ToString(); TempData["Emsg"] = "Unsuccess"; return(RedirectToAction("Company_Entry")); } } }
public ActionResult CreateStudent(MultipleModel.StudentIndexModelVM request) { var messageList = new List<string>(); if(ModelState.IsValid) { using (var db = new ElectionDbContext()) { if(!(db.Students.Where(s => s.StudentNumber == request.CreateStudent.StudentNumber).Any())) { var newStudent = db.Students.Create(); newStudent.StudentNumber = request.CreateStudent.StudentNumber; newStudent.LastName = request.CreateStudent.LastName; newStudent.FirstName = request.CreateStudent.FirstName; newStudent.MiddleInitial = request.CreateStudent.MiddleInitial; newStudent.Gender = request.CreateStudent.Gender; newStudent.SectionId = request.CreateStudent.SectionId; newStudent.CreatedAt = DateTime.Now; db.Students.Add(newStudent); db.SaveChanges(); request.Error = false; string message = "You have successfully added "+ request.CreateStudent.StudentNumber; messageList.Add(message); request.Message = messageList; TempData["StudentIndexTD"] = request; return RedirectToAction("StudentIndex", new { id = request.CreateStudent.SectionId }); } else if (db.Students.Where(s => s.StudentNumber == request.CreateStudent.StudentNumber).Any()) { request.Error = true; string message = request.CreateStudent.StudentNumber + " is already existing!!"; messageList.Add(message); request.Message = messageList; TempData["StudentIndexTD"] = request; return RedirectToAction("StudentIndex", new { id = request.CreateStudent.SectionId }); } } } request.Error = true; request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["StudentIndexTD"] = request; return RedirectToAction("StudentIndex", new { id = request.CreateStudent.SectionId}); }
public ActionResult RegisterBuyer() { MultipleModel mymodel = new MultipleModel(); return(View(mymodel)); }
public ActionResult DeleteCollege(MultipleModel.CollegeModelVM request) { if (ModelState.IsValid) { using (var db = new ElectionDbContext()) { var college = db.Colleges.Find(request.DeleteCollege.CollegeId); if (college != null) { college.Deleted = true; college.UpdatedAt = DateTime.Now; db.SaveChanges(); request.Error = false; var messageList = new List<string>(); string message = "You have successfully deleted " + college.College + ""; messageList.Add(message); request.Message = messageList; TempData["GroupsIndexTD"] = request; return RedirectToAction("GroupsIndex", "Admin"); } else if (college == null) { request.Error = true; var messageList = new List<string>(); string message = "The college selected does not exist!"; messageList.Add(message); request.Message = messageList; TempData["GroupsIndexTD"] = request; return RedirectToAction("GroupsIndex", "Admin"); } } } request.Error = true; request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["GroupsIndexTD"] = request; return RedirectToAction("GroupsIndex", "Admin"); }
public ActionResult CreateElection(MultipleModel.ElectionIndexVM request) { var messageList = new List<string>(); if(ModelState.IsValid) { using( var db = new ElectionDbContext()) { if(!(db.Elections.Where(e => e.ElectionName == request.CreateElection.ElectionName).Any())) { var newElection = db.Elections.Create(); var startDate = request.CreateElection.StartDate; var startTime = request.CreateElection.StartTime; var endDate = request.CreateElection.EndDate; var endTime = request.CreateElection.EndTime; if (request.CreateElection.GroupId != null) { newElection.GroupId = request.CreateElection.GroupId; } newElection.ElectionName = request.CreateElection.ElectionName; newElection.Id = request.CreateElection.GroupId; newElection.StartDateTime = new DateTime(startDate.Year, startDate.Month, startDate.Day, startTime.Hour, startTime.Minute, startTime.Second); newElection.EndDateTime = new DateTime(endDate.Year, endDate.Month, endDate.Day, endTime.Hour, endTime.Minute, endTime.Second); newElection.CreatedAt = DateTime.Now; db.Elections.Add(newElection); db.SaveChanges(); request.Error = false; string message = "You have successfully created " + newElection.ElectionName; messageList.Add(message); request.Message = messageList; TempData["ElectionIndexTD"] = request; return RedirectToAction("ElectionsIndex", "Admin"); } else if (db.Elections.Where(e => e.ElectionName == request.CreateElection.ElectionName).Any()) { request.Error = true; string message = request.CreateElection.ElectionName + " is already existing!"; messageList.Add(message); request.Message = messageList; TempData["ElectionIndexTD"] = request; return RedirectToAction("ElectionsIndex", "Admin"); } } } request.Error = true; request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["ElectionIndexTD"] = request; return RedirectToAction("ElectionsIndex", "Admin"); }
public ActionResult T_Information_SaveEdit(MultipleModel model, List <HttpPostedFileBase> Insertfile, string SendEditFile, string CancleFile) { string SaveFileName = string.Empty; //string path = Server.MapPath("~/AttachFiles/"); if (!Directory.Exists(InformationFiles)) { Directory.CreateDirectory(InformationFiles); } var getExitFiles = Directory.GetFiles(InformationFiles); string MatchFiles = ""; if (!string.IsNullOrWhiteSpace(SendEditFile) || !string.IsNullOrWhiteSpace(CancleFile)) { MatchFiles = MatchEditFies(CancleFile, SendEditFile); } if (!String.IsNullOrWhiteSpace(MatchFiles.Replace(',', ' '))) { var EditFiles = MatchFiles.TrimEnd(',').Split(','); var k = EditFiles.Count(); if (EditFiles.Count() > 0) { while (k > 0) { foreach (var exfile in getExitFiles) { //var exitFile = (exfile.Split('\\'))[6].Split('.')[0]; var exitFile = exfile.Split('\\'); //string filename = exitFile[exitFile.Length - 1].Split('.')[0]; //if (filename == EditFiles[k - 1].Split('.')[0]) //{ // SaveFileName += filename + ","; //} string filename = exitFile[exitFile.Length - 1]; if (filename == EditFiles[k - 1]) { SaveFileName += filename + ","; } } k = k - 1; } } } if (Insertfile != null) { foreach (HttpPostedFileBase postedFile in Insertfile) { if (postedFile != null) { string fileName = Path.GetFileName(postedFile.FileName); postedFile.SaveAs(InformationFiles + fileName); SaveFileName += fileName + ","; } } } if (!String.IsNullOrWhiteSpace(SaveFileName)) { SaveFileName = SaveFileName.TrimEnd(','); var AttachFiles = SaveFileName.Split(','); for (int i = 0; i < AttachFiles.Length; i++) { if ((AttachFiles[i] != null) || (AttachFiles[i].Trim().Length != 0)) { if (i == 0) { model.TinfoModel.AttachedFile1 = AttachFiles[i].ToString(); } else if (i == 1) { model.TinfoModel.AttachedFile2 = AttachFiles[i].ToString(); } else if (i == 2) { model.TinfoModel.AttachedFile3 = AttachFiles[i].ToString(); } else { model.TinfoModel.AttachedFile4 = AttachFiles[i].ToString(); } } } } Boolean insertflag = true; InformationBL ibl = new InformationBL(); model.TinfoModel.InsertOperator = Session["CompanyCD"].ToString(); string PcName = System.Environment.MachineName; if (model.TinfoModel.InformationID == 0) { insertflag = ibl.News_Editor_Save(model, PcName); if (insertflag) { TempData["Save"] = "Save Successfully"; } else { TempData["Nosave"] = "Save Failed"; } } else { insertflag = ibl.News_Editor_Save(model, PcName); if (insertflag) { TempData["update"] = "Updated Successfully"; } else { TempData["noupdate"] = "Update Failed"; } } return(RedirectToAction("News_Editor")); }
public Boolean News_Editor_Save(MultipleModel model, string PcName) { try { BaseDL bdl = new BaseDL(); DataTable dtinfo = new DataTable(); SqlParameter[] prms = new SqlParameter[17]; prms[0] = new SqlParameter("@destinationflag", SqlDbType.Int) { Value = model.TinfoModel.DestinationFlag }; if (model.ComModel != null) { prms[1] = new SqlParameter("@companyCD", SqlDbType.VarChar) { Value = model.ComModel.CompanyCD } } ; else { prms[1] = new SqlParameter("@companyCD", SqlDbType.VarChar) { Value = DBNull.Value } }; if (model.GroupModel != null) { prms[2] = new SqlParameter("@groupID", SqlDbType.VarChar) { Value = model.GroupModel.GroupID } } ; else { prms[2] = new SqlParameter("@groupID", SqlDbType.VarChar) { Value = DBNull.Value } }; if (model.TinfoModel.DisplayStartDate != DateTime.MinValue) { prms[3] = new SqlParameter("@startdate", SqlDbType.VarChar) { Value = model.TinfoModel.DisplayStartDate } } ; else { prms[3] = new SqlParameter("@startdate", SqlDbType.VarChar) { Value = DateTime.MinValue } }; if (model.TinfoModel.DisplayEndDate != DateTime.MinValue) { prms[4] = new SqlParameter("@enddate", SqlDbType.VarChar) { Value = model.TinfoModel.DisplayEndDate } } ; else { prms[4] = new SqlParameter("@enddate", SqlDbType.VarChar) { Value = DateTime.MinValue } }; prms[5] = new SqlParameter("@infotype", SqlDbType.VarChar) { Value = model.TinfoModel.InformationType }; if (model.TinfoModel.EffectFlag == true) { prms[6] = new SqlParameter("@effectflag", SqlDbType.Int) { Value = 0 } } ; else { prms[6] = new SqlParameter("@effectflag", SqlDbType.Int) { Value = 1 } }; if (model.TinfoModel.Date != DateTime.MinValue) { prms[7] = new SqlParameter("@date", SqlDbType.VarChar) { Value = model.TinfoModel.Date } } ; else { prms[7] = new SqlParameter("@date", SqlDbType.VarChar) { Value = DateTime.MinValue } }; prms[8] = new SqlParameter("@titlename", SqlDbType.VarChar) { Value = model.TinfoModel.TitleName }; if (model.TinfoModel.AttachedFile1 != null) { prms[9] = new SqlParameter("@file1", SqlDbType.VarChar) { Value = model.TinfoModel.AttachedFile1 } } ; else { prms[9] = new SqlParameter("@file1", SqlDbType.VarChar) { Value = DBNull.Value } }; if (model.TinfoModel.AttachedFile2 != null) { prms[10] = new SqlParameter("@file2", SqlDbType.VarChar) { Value = model.TinfoModel.AttachedFile2 } } ; else { prms[10] = new SqlParameter("@file2", SqlDbType.VarChar) { Value = DBNull.Value } }; if (model.TinfoModel.AttachedFile3 != null) { prms[11] = new SqlParameter("@file3", SqlDbType.VarChar) { Value = model.TinfoModel.AttachedFile3 } } ; else { prms[11] = new SqlParameter("@file3", SqlDbType.VarChar) { Value = DBNull.Value } }; if (model.TinfoModel.AttachedFile4 != null) { prms[12] = new SqlParameter("@file4", SqlDbType.VarChar) { Value = model.TinfoModel.AttachedFile4 } } ; else { prms[12] = new SqlParameter("@file4", SqlDbType.VarChar) { Value = DBNull.Value } }; if (model.TinfoModel.DetailInformation != null) { prms[13] = new SqlParameter("@detail", SqlDbType.VarChar) { Value = model.TinfoModel.DetailInformation } } ; else { prms[13] = new SqlParameter("@detail", SqlDbType.VarChar) { Value = DBNull.Value } }; prms[14] = new SqlParameter("@insertoperator", SqlDbType.VarChar) { Value = model.TinfoModel.InsertOperator }; prms[15] = new SqlParameter("@AccessPC", SqlDbType.VarChar) { Value = PcName }; if (model.TinfoModel.InformationID != 0) { prms[16] = new SqlParameter("@InformationID", SqlDbType.Int) { Value = model.TinfoModel.InformationID } } ; else { prms[16] = new SqlParameter("@InformationID", SqlDbType.Int) { Value = 0 } }; bdl.InsertUpdateDeleteData("News_Editor_Insert", prms); return(true); } catch (Exception ex) { return(false); } }
public ActionResult UpdateUser(MultipleModel.UserInformationVM vm) { var errorList = new List<string>(); string message = null; var user = db.Users.SingleOrDefault(u=>u.Id == vm.User.Id); if(user != null) { if(ModelState.IsValid) { user.Student.FirstName = vm.NewUserInfo.FirstName; user.Student.MiddleInitial = vm.NewUserInfo.MiddleInitial; user.Student.LastName = vm.NewUserInfo.LastName; user.Student.Gender = vm.NewUserInfo.Gender; user.Email = vm.NewUserInfo.EmailAddress; user.UpdatedAt = DateTime.Now; user.Student.UpdatedAt = DateTime.Now; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); vm.Error = false; message = "You have successfully updated " + user.Student.LastName + "'s information"; errorList.Add(message); vm.Message = errorList; TempData["UserInformationTD"] = vm; return RedirectToAction("UserInformation", new { id = vm.User.Id }); } else { vm.Error = true; vm.Message = CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["UserInformationTD"] = vm; return RedirectToAction("UserInformation", new { id = vm.User.Id }); } } vm.Error = true; message = "The selected user doesn't exist"; errorList.Add(message); vm.Message = errorList; TempData["UserInformationTD"] = vm; return RedirectToAction("UserInformation", new { id = vm.User.Id}); }
// GET: Registrations public ActionResult Company_Entry(string id) { MultipleModel model = new MultipleModel(); if (Session["CompanyCD"] != null) { if (id != null) { ViewBag.Flag = id; try { M_CompanyModel MCmodel = new M_CompanyModel(); M_CompanyTagModel t = new M_CompanyTagModel(); //M_CompanyBrandModel MCBmodel = new M_CompanyBrandModel(); M_BrandModel MBmodel = new M_BrandModel(); //M_CompanyShippingModel ms = new M_CompanyShippingModel(); //List<M_CompanyShippingModel> MSmodel = new List<M_CompanyShippingModel>(); List <M_CompanyTagModel> MTmodel = new List <M_CompanyTagModel>(); Company_EntryBL bl = new Company_EntryBL(); DataSet dsnew = bl.CompanyUpdateView_Edit(id); if (dsnew.Tables.Count > 0) { int count = dsnew.Tables.Count; for (int i = 0; i < count; i++) { DataTable dt = dsnew.Tables[i]; if (dt.Rows.Count > 0) { DataColumnCollection columns = dt.Columns; if (columns.Contains("CompanyName")) { MCmodel.CompanyCD = dt.Rows[0]["CompanyCD"].ToString(); MCmodel.CompanyName = dt.Rows[0]["CompanyName"].ToString(); MCmodel.Password = dt.Rows[0]["Password"].ToString(); MCmodel.UserRole = Convert.ToInt32(dt.Rows[0]["UserRole"]); MCmodel.ShortName = dt.Rows[0]["ShortName"].ToString(); MCmodel.ZipCD1 = dt.Rows[0]["CompanyZipCD"].ToString(); MCmodel.Address1 = dt.Rows[0]["Address1"].ToString(); MCmodel.Address2 = dt.Rows[0]["Address2"].ToString(); MCmodel.TelephoneNo = dt.Rows[0]["TelephoneNo"].ToString(); MCmodel.FaxNo = dt.Rows[0]["FaxNo"].ToString(); MCmodel.PresidentName = dt.Rows[0]["PresidentName"].ToString(); if (String.IsNullOrWhiteSpace(dt.Rows[0]["RankingFlg"].ToString())) { MCmodel.RankingFlg = 2; } else { MCmodel.RankingFlg = Convert.ToInt32(dt.Rows[0]["RankingFlg"]); } } //if (columns.Contains("ShippingID")) //{ // //DataView view1 = new DataView(dt); // //DataTable distinctValues1 = view1.ToTable(true, "ShippingID", "ShippingName", "ShippingZipCD", "ShippingAddress1", "ShippingAddress2", "ShippingTelephoneNo","ShippingFaxNo"); // MSmodel = dt.AsEnumerable().Select(r => // new M_CompanyShippingModel // { // ShippingID = Convert.ToInt32(r["ShippingID"]), // ShippingName = r["ShippingName"].ToString(), // ZipCD1 = r["ShippingZipCD"].ToString(), // Address1 = r["ShippingAddress1"].ToString(), // Address2 = r["ShippingAddress2"].ToString(), // TelephoneNO = r["ShippingTelephoneNo"].ToString(), // FaxNO = r["ShippingFaxNo"].ToString() // }).Distinct().ToList(); //} if (columns.Contains("Tag")) { DataView view = new DataView(dt); DataTable distinctValues = view.ToTable(true, "CompanyCD", "Tag"); MTmodel = distinctValues.AsEnumerable().Select(r => new M_CompanyTagModel { CompanyCD = r["CompanyCD"].ToString(), Tag = r["Tag"].ToString() } ).Distinct().ToList(); } if (columns.Contains("BrandName")) { MBmodel.BrandName = dt.Rows[0]["BrandName"].ToString(); } } } } //if (MSmodel.Count < 5) //{ // int sc = MSmodel.Count; // int tc = 4; // int nq = tc - sc; // int O = nq + sc; // for (int P = sc; P < O; P++) // { // ms.CompanyCD = ""; // ms.ShippingID = null; // ms.ShippingName = ""; // ms.ZipCD1 = ""; // ms.ZipCD2 = ""; // ms.Address1 = ""; // ms.Address2 = ""; // ms.TelephoneNO = ""; // ms.FaxNO = ""; // MSmodel.Add(ms); // } //} int N = MTmodel.Count; int M = 20; int NK = M - N; int n = N + NK; for (int j = N; j < n; j++) { t.CompanyCD = ""; t.Tag = ""; MTmodel.Add(t); } model.TagModel = MTmodel; //model.ShippingModel = MSmodel; model.ComModel = MCmodel; model.MBrandModel = MBmodel; DataTable dtinfo1 = new DataTable(); Company_EntryBL cbl = new Company_EntryBL(); dtinfo1 = cbl.Get_MoreShipping_ForEdit(id); int totalcount = 0; if (dtinfo1.Rows.Count > 0) { totalcount = dtinfo1.Rows.Count + 1; ViewBag.Totalcount = totalcount; } } catch (Exception ex) { } } else { ViewBag.Flag = ""; } return(View(model)); } else { return(RedirectToAction("Login", "User")); } }
public ActionResult UpdateStudent(MultipleModel.StudentIndexModelVM request) { var messageList = new List<string>(); if (ModelState.IsValid) { using (var db = new ElectionDbContext()) { var getStudent = db.Students.Find(request.UpdateUser.StudentId); if (getStudent != null) { if(!(db.Students.Where(s => s.StudentNumber == request.UpdateUser.StudentNumber).Any()) || (getStudent.StudentNumber == request.UpdateUser.StudentNumber)) { getStudent.StudentNumber = request.UpdateUser.StudentNumber; getStudent.LastName = request.UpdateUser.LastName; getStudent.FirstName = request.UpdateUser.FirstName; getStudent.MiddleInitial = request.UpdateUser.MiddleInitial; getStudent.Gender = request.UpdateUser.Gender; getStudent.UpdatedAt = DateTime.Now; db.Entry(getStudent).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); request.Error = false; string message = "You have successfully updated student (" + getStudent.StudentNumber + ")"; messageList.Add(message); request.Message = messageList; TempData["StudentIndexTD"] = request; return RedirectToAction("StudentIndex", new { id = request.SectionId }); } else if (db.Students.Where(s => s.StudentNumber == request.UpdateUser.StudentNumber).Any()) { request.Error = true; string message = "The student number "+ request.UpdateUser.StudentNumber+" is already existing!!"; messageList.Add(message); request.Message = messageList; TempData["StudentIndexTD"] = request; return RedirectToAction("StudentIndex", new { id = request.SectionId }); } } else if (getStudent == null) { request.Error = true; string message = "The selected student does not exist!!"; messageList.Add(message); request.Message = messageList; TempData["StudentIndexTD"] = request; return RedirectToAction("StudentIndex", new { id = request.SectionId }); } } } request.Error = true; request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["StudentIndexTD"] = request; return RedirectToAction("StudentIndex", new { id = request.SectionId }); }
public ActionResult CreateSection(MultipleModel.SectionModelVM request) { var messageList = new List<string>(); if (ModelState.IsValid) { using (var db = new ElectionDbContext()) { if (!(db.Sections.Where(m => m.Section == request.CreateSection.SectionName).Any())) { var newSection = db.Sections.Create(); newSection.MajorId = request.CreateSection.MajorId; newSection.Section = request.CreateSection.SectionName; newSection.CreatedAt = DateTime.Now; db.Sections.Add(newSection); db.SaveChanges(); request.Error = false; string message = "You have successfully added " + newSection.Section + ""; messageList.Add(message); request.Message = messageList; TempData["SectionIndexTD"] = request.Error; TempData["SectionIndexTD"] = request.Message; return RedirectToAction("SectionIndex", new { id = request.CreateSection.MajorId }); } else if (db.Sections.Where(m => m.Section == request.CreateSection.SectionName).Any()) { request.Error = true; string message = request.CreateSection.SectionName + " is already existing!!"; messageList.Add(message); request.Message = messageList; TempData["SectionIndexTD"] = request; return RedirectToAction("SectionIndex", new { id = request.CreateSection.MajorId }); } } } request.Error = true; request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["SectionIndexTD"] = request; return RedirectToAction("SectionIndex", new { id = request.CreateSection.MajorId }); }
public ActionResult Login(MultipleModel.LoginPageVM request) { if(ModelState.IsValid) { using (var db = new ElectionDbContext()) { var crypto = new SimpleCrypto.PBKDF2(); var emailCheck = db.Users.SingleOrDefault(u => u.Email == request.Auth.Email); var getPasswordSalt = emailCheck.PasswordSalt; if ((emailCheck != null) && (getPasswordSalt != null) && (emailCheck.Deleted == false) && (emailCheck.Status == true)) { var materializePasswordSalt = getPasswordSalt.ToList(); var encryptedPassword = crypto.Compute(request.Auth.Password, getPasswordSalt); if (request.Auth.Email != null && emailCheck.Password == encryptedPassword) { var fullname = emailCheck.Student.FirstName + " " + emailCheck.Student.MiddleInitial + " " + emailCheck.Student.LastName; var email = emailCheck.Email; var role = emailCheck.Role; var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, fullname), new Claim(ClaimTypes.Email, email), new Claim(ClaimTypes.Role, role) }, "ApplicationCookie"); var ctx = Request.GetOwinContext(); var authManager = ctx.Authentication; authManager.SignIn(identity); if (emailCheck.Role == "administrator") { return RedirectToAction("GroupsIndex", "Admin"); } else { return RedirectToAction("Index", "Auth"); } } else { request.Error = true; ModelState.AddModelError("", "Invalid email or password"); } } else if ((emailCheck != null) && (emailCheck.Status == false) && (emailCheck.Deleted == false)) { request.Error = true; ModelState.AddModelError("", "Please activate the account"); } else if (emailCheck == null || ((emailCheck.Deleted == true) && (emailCheck.Status == false))) { request.Error = true; ModelState.AddModelError("", "Account does not exist"); } } } request.Error = true; request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["LoginTempData"] = request; return RedirectToAction("Login", "Auth"); }
public ActionResult SetProfilePicture(HttpPostedFileBase img, MultipleModel.ProfileVM prof) { return View(); }
public ActionResult ActivateAccount(MultipleModel.LoginPageVM request) { var messageList = new List<string>(); if (ModelState.IsValid) { using (var db = new ElectionDbContext()) { var getUser = db.Users.Where(u=>u.Deleted == false).SingleOrDefault(u => u.Email == request.Activation.Email); if(getUser != null) { if(getUser.Status == false) { var crypto = new SimpleCrypto.PBKDF2(); var encryptedPinCode = crypto.Compute(request.Activation.Pincode, getUser.PincodeSalt); if (getUser.Pincode == encryptedPinCode) { var ctx = Request.GetOwinContext(); var authManager = ctx.Authentication; var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, getUser.Email), new Claim(ClaimTypes.Role, "activation") }, "ApplicationCookie"); authManager.SignIn(identity); return RedirectToAction("ActivateAccount", new { id = getUser.Id }); } else if (getUser.Pincode != encryptedPinCode) { request.Error = true; string message = "Invalid pincode"; messageList.Add(message); request.Message = messageList; TempData["LoginTempData"] = request; return RedirectToAction("Login", "Auth"); } } else if (getUser.Status == true) { request.Error = true; string message = getUser.Email +" is already activated"; messageList.Add(message); request.Message = messageList; TempData["LoginTempData"] = request; return RedirectToAction("Login", "Auth"); } } else if (getUser == null) { request.Error = true; string message = "Invalid email address"; messageList.Add(message); request.Message = messageList; TempData["LoginTempData"] = request; return RedirectToAction("Login", "Auth"); } } } request.Error = true; request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["LoginTempData"] = request; return RedirectToAction("Login", "Auth"); }
public ActionResult CreateSection(MultipleModel.CreateSectionVM vm) { if (ModelState.IsValid) { using (var db = new LibraryDbContext()) { if (db.Sections.Where(u => u.Section == vm.CreateSection.Section).Any()) { vm.Error = true; var errorList = new List<string>(); string message = "Section " + vm.CreateSection.Section + " is already existing"; errorList.Add(message); vm.Message = errorList; TempData["AddSection"] = vm; return RedirectToAction("SectionIndex", new { id = vm.GroupID }); } else { var grade = db.Grades.Find(vm.GroupID); var section = db.Sections.Create(); section.Section = vm.CreateSection.Section; section.CreatedAt = DateTime.Now; grade.Sections.Add(section); db.SaveChanges(); vm.Error = false; var errorList = new List<string>(); string message = "You have successfully added a section(" + vm.CreateSection.Section + ")"; errorList.Add(message); vm.Message = errorList; TempData["UserRegistration"] = vm; return RedirectToAction("SectionIndex", new { id = section.GradeId }); } } } vm.Error = true; vm.Message = CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["AddSection"] = vm; return RedirectToAction("SectionIndex", new { id = vm.GroupID }); }
public ActionResult DeleteSection(MultipleModel.SectionModelVM request) { if (ModelState.IsValid) { using (var db = new ElectionDbContext()) { var section = db.Sections.Find(request.DeleteSection.SectionId); if (section != null) { section.Deleted = true; section.UpdatedAt = DateTime.Now; db.SaveChanges(); request.Error = false; var messageList = new List<string>(); string message = "You have successfully deleted " + section.Section + ""; messageList.Add(message); request.Message = messageList; TempData["SectionIndexTD"] = request; return RedirectToAction("SectionIndex", new { id = request.MajorId }); } else if (section == null) { request.Error = true; var messageList = new List<string>(); string message = "The section selected does not exist!"; messageList.Add(message); request.Message = messageList; TempData["SectionIndexTD"] = request; return RedirectToAction("SectionIndex", new { id = request.MajorId }); } } } request.Error = true; request.Message = CustomClass.CustomValidationMessage.GetErrorList(ViewData.ModelState); TempData["SectionIndexTD"] = request; return RedirectToAction("SectionIndex", new { id = request.MajorId }); }
// GET: Delimer public ActionResult Delimer(MultipleModel model) { ViewBag.rezult = model.Number / 2; return(View()); }
public ActionResult CreateUser(MultipleModel.UserIndexVM reg) { if (ModelState.IsValid) { if (db.Users.Where(u => u.Email == reg.Register.EmailAddress).Any()) { reg.Error = true; var errorList = new List<string>(); string message = "Email " + reg.Register.EmailAddress + " is already existing"; errorList.Add(message); reg.Message = errorList; TempData["UserIndexTD"] = reg; return RedirectToAction("UserIndex", new { id = reg.SectionID }); } else { using (var db = new LibraryDbContext()) { var newUser = db.Users.Create(); string pin = RandomPassword.Generate(6, PasswordGroup.Lowercase, PasswordGroup.Lowercase, PasswordGroup.Numeric); var crypto = new PBKDF2(); var encrypPin = crypto.Compute(pin); newUser.Pincode = encrypPin; newUser.PincodeSalt = crypto.Salt; newUser.Email = reg.Register.EmailAddress; newUser.Role = "student"; newUser.CreatedAt = DateTime.Now; newUser.UpdatedAt = DateTime.Now; db.Users.Add(newUser); var newStudent = db.Students.Create(); var section = db.Sections.FirstOrDefault(s => s.Id == reg.SectionID); newStudent.SectionId = section.Id; newStudent.FirstName = reg.Register.FirstName; newStudent.MiddleInitial = reg.Register.MiddleInitial; newStudent.LastName = reg.Register.LastName; newStudent.Gender = reg.Register.Gender; newStudent.CreatedAt = DateTime.Now; newStudent.UpdatedAt = DateTime.Now; db.Students.Add(newStudent); db.SaveChanges(); SMTP smtp = new SMTP(); smtp.SendEmal(newUser.Email, pin); reg.Error = false; var errorList = new List<string>(); string message = "You have successfully added a user(" + newUser.Email + ")"; errorList.Add(message); reg.Message = errorList; TempData["UserIndexTD"] = reg; return RedirectToAction("UserIndex", new { id = reg.SectionID }); } } } else { reg.Error = true; reg.Message = CustomValidationMessage.GetErrorList(ViewData.ModelState); } TempData["UserIndexTD"] = reg; return RedirectToAction("UserIndex", new { id = reg.SectionID }); }