public ActionResult Create(RoomAssign roomAssign) { if (AdminSessionControl()) { var check = _roomAssign.CountRoomAssign(roomAssign); if (ModelState.IsValid) { if (check) { ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode", roomAssign.DepartmentId); ViewBag.Room = new SelectList(db.Rooms, "Id", "RoomNo"); ViewBag.Day = new SelectList(db.Day, "Id", "DayName"); ViewBag.Message = "This Room is Assign for this time "; roomAssign = null; return(View(roomAssign)); } else { db.RoomAssigns.Add(roomAssign); db.SaveChanges(); return(RedirectToAction("Index")); } } ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode", roomAssign.DepartmentId); ViewBag.Room = new SelectList(db.Rooms, "Id", "RoomNo"); ViewBag.Day = new SelectList(db.Day, "Id", "DayName"); return(View(roomAssign)); } else { return(AdminLoginFaild()); } }
public ActionResult Create([Bind(Include = "TermDepositID,Deposit,TermCreation")] TermDeposit termDeposit) { if (ModelState.IsValid) { db.termDeposits.Add(termDeposit); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(termDeposit)); }
public ActionResult Create([Bind(Include = "AccountID,AccountClientID,AccountBalance,AccountType,AccountCreationDate")] BankAccountModel bankaccountmodel) { if (ModelState.IsValid) { db.Accounts.Add(bankaccountmodel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bankaccountmodel)); }
public ActionResult Create([Bind(Include = "Id,Content,StudentId,DepartmentId,BatchId,DateTime,FilePath")] StudentGroupContent studentGroupContent) { if (ModelState.IsValid) { db.StudentGroupContent.Add(studentGroupContent); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(studentGroupContent)); }
public ActionResult Create(AccountDetail accountDetail) { if (ModelState.IsValid) { db.AccountInfos.Add(accountDetail); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", accountDetail.CustomerID); return(View(accountDetail)); }
public ActionResult Create([Bind(Include = "LoanId,LoanAmount,CustomerID")] Loan loan) { if (ModelState.IsValid) { db.Loans.Add(loan); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", loan.CustomerID); return(View(loan)); }
public ActionResult Create([Bind(Include = "AccountID,AccountType,CreationDate,Balance,CustomerID,TermDepositID")] AccountDetail accountDetail) { if (ModelState.IsValid) { db.AccountInfos.Add(accountDetail); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", accountDetail.CustomerID); return(View(accountDetail)); }
public ActionResult UnassignCourse(UnassignCourse _unassignCourse) { //room remove if (AdminSessionControl()) { var _roomAssign = db.RoomAssigns.Where( x => x.DepartmentId == _unassignCourse.DepartmentId && x.BatchId == _unassignCourse.BatchId && x.SemesterId == _unassignCourse.Semester).ToList(); foreach (var item in _roomAssign) { db.RoomAssigns.Remove(item); } //course unassigned var query = db.CourseAssigns.Where( x => x.DepartmentId == _unassignCourse.DepartmentId && x.BatchId == _unassignCourse.BatchId) .Join(db.Courses, c => c.CourseId, s => s.Id, (c, s) => new { c, s }) .Where(x => x.s.Semester == _unassignCourse.Semester).Select(z => z.c); foreach (CourseAssign item in query) { item.Flag = 0; item.Credit = 0; } db.SaveChanges(); ViewBag.Message = "Course Unassign Successfully"; ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode"); return(View()); } else { return(AdminLoginFaild()); } }
public ActionResult Create([Bind(Include = "Id,DepartmentCode,DepartmentName")] Department department) { if (AdminSessionControl()) { if (ModelState.IsValid) { db.Departments.Add(department); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(department)); } else { return(AdminLoginFaild()); } }
public ActionResult Create([Bind(Include = "Id,DayName")] Day day) { if (AdminSessionControl()) { if (ModelState.IsValid) { db.Day.Add(day); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(day)); } else { return(AdminLoginFaild()); } }
public ActionResult Create([Bind(Include = "Id,RoomNo,Description")] Room room) { if (AdminSessionControl()) { if (ModelState.IsValid) { db.Rooms.Add(room); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(room)); } else { return(AdminLoginFaild()); } }
public ActionResult FacultyResetRequest(string Email) { if (Email != null) { ResetPassword _reset = new ResetPassword(); int CheckExistance = db.Teachers.Where(x => x.Email == Email).Select(y => y.Id).FirstOrDefault(); if (CheckExistance > 0) { //make 2 random Number RandomNumber _ran = new RandomNumber(); string RandomNumber1 = _ran.Random(10); string RandomNumber2 = _ran.Random(8); UserIPAddress _ipAddress = new UserIPAddress(); _reset.UserIP = _ipAddress.GetUserIp(); _reset.Email = Email; _reset.RandomNumber = RandomNumber1; _reset.RandomNumber2 = RandomNumber2; _reset.DateTime = DateTime.Now; _reset.AccountId = CheckExistance; db.ResetPassword.Add(_reset); db.SaveChanges(); string Sub = "Reset Password"; string Link = "http://localhost:56969/ResetPassword/FacultyReset?Id1=" + RandomNumber1 + "&Id2=" + RandomNumber2; string Message = "<a href='" + Link + "'><b>localhost:56969/ResetPassword/FacultyReset?Id1=" + RandomNumber1 + "&Id2=" + RandomNumber2 + "</b></a> : Ip Address : " + _reset.UserIP; try { Mail _mail = new Mail(); _mail.SendMail(_reset.Email, Sub, Message); } catch (Exception) { ViewBag.Message = "Internet Not Supporting at this time try again later"; return(View()); } ViewBag.Message = "Check Your Email You have received a Link to reset your password"; return(View()); } } ViewBag.Message = "Enter Valid Email"; return(View()); }
public ActionResult Create([Bind(Include = "Id,BatchNo,DepartmentId")] Batch batch) { if (AdminSessionControl()) { if (ModelState.IsValid) { db.Batchs.Add(batch); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode", batch.DepartmentId); return(View(batch)); } else { return(AdminLoginFaild()); } }
public ActionResult Create([Bind(Include = "CustomerID,FirstName,LastName,UserID")] Customer customer) { if (ModelState.IsValid) { var email = Session["username"] as string; var userDb = new ApplicationDbContext(); var user = userDb.Users.Where(u => u.Email == email).SingleOrDefault <ApplicationUser>(); if (user != null) { customer.UserID = user.Id; } db.Customers.Add(customer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Create([Bind(Include = "Id,CourseCode,CourseName,Credit,Description,Semester,DepartmentId")] Course course) { if (AdminSessionControl()) { if (ModelState.IsValid) { db.Courses.Add(course); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode", course.DepartmentId); return(View(course)); } else { return(AdminLoginFaild()); } }
public ActionResult Delete() { var db = new AccountDBContext(); Account acc = db.Accounts.Where(p => p.Name == "blog").FirstOrDefault(); JavaScriptSerializer marshal = new JavaScriptSerializer(); var clear = new List <Dictionary <string, string> >(); string emptyJson = marshal.Serialize(clear); acc.layoutJSON = emptyJson; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Register(UserAccount account) { if (ModelState.IsValid) { using (AccountDBContext db = new AccountDBContext()) { db.userAccount.Add(account); db.SaveChanges(); } ModelState.Clear(); ViewBag.Message = account.firstName + " " + account.lastName + " successfully registered"; } return(View()); }
public ActionResult DeleteConfirmed(int id) { AccountDBContext db2 = new AccountDBContext(); UtilityBillModel utilitybillmodel = db.UtilityBills.Find(id); var accSum = from a in db2.Accounts where a.AccountID.Equals(utilitybillmodel.AccountToPayID) select a.AccountBalance; //Check if account exists if (accSum != null) { //Check if account sum is greater than the bill if (accSum.FirstOrDefault() >= utilitybillmodel.AmountToPay) //pay { var accountToUpdate = db2.Accounts.Where(o => o.AccountID == utilitybillmodel.AccountToPayID); // update LastName for all Persons in personsToUpdate foreach (BankAccountModel p in accountToUpdate) { p.AccountBalance = accSum.FirstOrDefault() - utilitybillmodel.AmountToPay; } db.UtilityBills.Remove(utilitybillmodel); db.SaveChanges(); db2.SaveChanges(); String currentUser = User.Identity.Name; db1.Loggers.Add( new LoggerModel { dateLog = DateTime.Now, userNameLog = currentUser, transactionLog = "Utility payed for " + utilitybillmodel.AccountToPayID + " for amount " + utilitybillmodel.AmountToPay } ); db1.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Error1")); } } //If account does not exist else { return(RedirectToAction("Error")); } }
public ActionResult NewPanel(string q) { var db = new AccountDBContext(); Account acc = db.Accounts.Where(p => p.Name == "blog").FirstOrDefault(); JavaScriptSerializer marshal = new JavaScriptSerializer(); ViewBag.Panels = marshal.Deserialize <List <Dictionary <string, string> > >(acc.layoutJSON); if (q != null) { var dict = marshal.Deserialize <Dictionary <string, string> >(q); ViewBag.Panels.Add(dict); string newJson = marshal.Serialize(ViewBag.Panels); acc.layoutJSON = newJson; db.SaveChanges(); } return(View("Index")); }
public ActionResult Create(ShareContent ShareContent, HttpPostedFileBase Myfile) { if (AdminSessionControl()) { if (ModelState.IsValid) { string PathAddress = ""; string PathAddress2 = ""; if (Myfile != null) { RandomNumber _ran = new RandomNumber(); string Random = _ran.Random(10); string Random2 = _ran.Random(8); string _FileName = System.IO.Path.GetFileName(ShareContent.DepartmentID + ShareContent.BatchId + Random + Random2 + Myfile.FileName); PathAddress = Path.Combine(Server.MapPath("~/ShareFiles"), _FileName); PathAddress2 = "ShareFiles/" + _FileName; Myfile.SaveAs(PathAddress); } // ShareContent.Message = ShareContent.Message.Replace("[\r\n]", " <br /> "); ShareContent.PosterId = Convert.ToInt16(Session["AdminId"]); ShareContent.DateTime = DateTime.Now; ShareContent.FilePath = PathAddress2; ShareContent.Flag = 1; db.ShareContents.Add(ShareContent); db.SaveChanges(); Mail _mail = new Mail(); // _mail.SendMail("*****@*****.**", "Test", "Test Mail From IIT"); return(RedirectToAction("AdminView", "ShareContentAdmin")); } ViewBag.DepartmentID = new SelectList(db.Departments, "Id", "DepartmentCode", ShareContent.DepartmentID); return(View(ShareContent)); } else { return(AdminLoginFaild()); } }
public ActionResult Register(MasterUserAccount account) { AccountDBContext DB = new AccountDBContext(); var isExist = DB.MasterUserAccounts.Count(x => x.Email == account.Email); Password password = new Password(); int PasswordStatus = password.CheckStrength(account.Password); if (ModelState.IsValid) { if (PasswordStatus >= 4) { if (isExist == 0) { //encript password here byte[] bytes = Encoding.Unicode.GetBytes(account.Password); byte[] inArray = HashAlgorithm.Create("SHA1").ComputeHash(bytes); account.Password = Convert.ToBase64String(inArray); account.ConfirmPassword = Convert.ToBase64String(inArray); DB.MasterUserAccounts.Add(account); DB.SaveChanges(); ModelState.Clear(); ViewBag.Message = "User" + account.FirstName + " " + account.LastName + " is Successfully Registered"; return(View()); } else { ViewBag.Message = "User Already Exist"; return(View()); } } else { ViewBag.Message = "Password Not Strong"; return(View()); } } return(View()); }
public ActionResult Create(Student student, HttpPostedFileBase PhotoPath2) { if (AdminSessionControl()) { if (ModelState.IsValid) { try { string PathAddress = ""; string PathAddress2 = ""; Password password = new Password(); int PasswordStatus = password.CheckStrength(student.Password); var ExistEmail = db.Students.Where(w => w.Email == student.Email); var ExistReg = db.Students.Where(w => w.RegNo == student.RegNo).Count(); if (PasswordStatus < 4) { ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode", student.DepartmentId); ViewBag.Message = "Password Not strong: one capital letter, one small Letter, one digit and one special charecture needed "; student.Password = ""; student.ConfirmPassword = ""; return(View(student)); } else if (PhotoPath2 == null && PhotoPath2.ContentLength < 0) { ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode", student.DepartmentId); ViewBag.Message = "Photo Not Acceptable"; student.Password = ""; student.ConfirmPassword = ""; return(View(student)); } else if (ExistEmail.Count() > 0) { ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode", student.DepartmentId); ViewBag.Message = "Email Address Already Existed"; student.Password = ""; student.ConfirmPassword = ""; return(View(student)); } else if (ExistReg > 0) { ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode", student.DepartmentId); ViewBag.Message = "Reg Number Already Existed"; student.Password = ""; student.ConfirmPassword = ""; return(View(student)); } else { //Photo Upload RandomNumber _ran = new RandomNumber(); string Random = _ran.Random(10); string Random2 = _ran.Random(10); string _FileName = System.IO.Path.GetFileName(student.MobileNo + Random + Random2 + PhotoPath2.FileName); PathAddress = Path.Combine(Server.MapPath("~/ShareFiles/Students/"), _FileName); PathAddress2 = "ShareFiles/Students/" + _FileName; PhotoPath2.SaveAs(PathAddress); //encript password here byte[] bytes = Encoding.Unicode.GetBytes(student.Password); byte[] inArray = HashAlgorithm.Create("SHA1").ComputeHash(bytes); student.Password = Convert.ToBase64String(inArray); student.ConfirmPassword = Convert.ToBase64String(inArray); student.PhotoPath = PathAddress2; db.Students.Add(student); db.SaveChanges(); Mail _mail = new Mail(); // _mail.SendMail(student.Email, "Account Created From IIT System", "Dear Student greeting From IIT, This email is now registered to access IIT Course management System"); //Result Table will be created int StudentId = ExistEmail.FirstOrDefault().Id; var ListofCourse = db.Courses.Where(x => x.DepartmentId == ExistEmail.FirstOrDefault().DepartmentId).ToList(); foreach (var course in ListofCourse) { Result _result = new Result(); _result.StudentId = StudentId; _result.CourseId = course.Id; _result.Credit = course.Credit; db.Results.Add(_result); db.SaveChanges(); } return(RedirectToAction("Index")); } } catch (Exception) { ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode", student.DepartmentId); ViewBag.Message = "Something Wrong"; student.Password = ""; student.ConfirmPassword = ""; return(View(student)); } } ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode", student.DepartmentId); return(View(student)); } else { return(AdminLoginFaild()); } }
public ActionResult Create([Bind(Include = "Id,BatchId,CourseId,TeacherId,Credit,DepartmentId")] CourseAssign courseAssign) { if (AdminSessionControl()) { if (ModelState.IsValid) { int count = db.CourseAssigns.Count( x => x.DepartmentId == courseAssign.DepartmentId && x.BatchId == courseAssign.BatchId && x.TeacherId == courseAssign.TeacherId && x.CourseId == courseAssign.CourseId); var flag = db.CourseAssigns.Where(x => x.DepartmentId == courseAssign.DepartmentId && x.BatchId == courseAssign.BatchId && x.TeacherId == courseAssign.TeacherId && x.CourseId == courseAssign.CourseId) .Select(x => x.Flag).FirstOrDefault(); var Exist = db.CourseAssigns.Where(x => x.DepartmentId == courseAssign.DepartmentId && x.BatchId == courseAssign.BatchId && x.TeacherId == courseAssign.TeacherId && x.CourseId == courseAssign.CourseId) .Select(x => x).FirstOrDefault(); //Count Same Id Teacher Course er koyta ase if (count > 0) { if (flag == 0) { Exist.Flag = 1; Exist.Credit = courseAssign.Credit; db.SaveChanges(); ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode"); ViewBag.Message = "Assigned Again"; return(View(courseAssign)); } else { ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode"); ViewBag.Message = "Already Assigned"; courseAssign = null; return(View(courseAssign)); } } else { courseAssign.Flag = 1; db.CourseAssigns.Add(courseAssign); db.SaveChanges(); ViewBag.Message = " Assigned Successfully"; ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode"); return(View()); } } else { ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentCode"); return(View()); } } else { return(AdminLoginFaild()); } }
public void AddUser(User item) { context.Add(item); context.SaveChanges(); }
public int WriteChanges() { return(_context.SaveChanges()); }
public ActionResult Create([Bind(Include = "TransactionID,AccountFromID,AccountToID,TransactionAmount,TransactionDate")] TransactionModel transactionmodel) { if (ModelState.IsValid) { var clientID1 = from a in db2.Accounts where a.AccountID.Equals(transactionmodel.AccountFromID) select a.AccountClientID; var clientID2 = from a in db2.Accounts where a.AccountID.Equals(transactionmodel.AccountToID) select a.AccountClientID; if (clientID1 != null && clientID2 != null && transactionmodel.AccountFromID != transactionmodel.AccountToID) { var AccBalance1 = from a in db2.Accounts where a.AccountID.Equals(transactionmodel.AccountFromID) select a.AccountBalance; var AccBalance2 = from a in db2.Accounts where a.AccountID.Equals(transactionmodel.AccountToID) select a.AccountBalance; if (AccBalance1.FirstOrDefault() - transactionmodel.TransactionAmount >= 0) { var accountToUpdateFrom = db2.Accounts.Where(o => o.AccountID == transactionmodel.AccountFromID); var accountToUpdateTo = db2.Accounts.Where(o => o.AccountID == transactionmodel.AccountToID); // update LastName for all Persons in personsToUpdate foreach (BankAccountModel p in accountToUpdateFrom) { p.AccountBalance = AccBalance1.FirstOrDefault() - transactionmodel.TransactionAmount; } foreach (BankAccountModel p in accountToUpdateTo) { p.AccountBalance = AccBalance2.FirstOrDefault() + transactionmodel.TransactionAmount; } db.Transactions.Add(transactionmodel); db.SaveChanges(); db2.SaveChanges(); String currentUser = User.Identity.Name; db3.Loggers.Add( new LoggerModel { userNameLog = currentUser, dateLog = DateTime.Now, transactionLog = "Transfer: " + transactionmodel.AccountFromID.ToString() + " to " + transactionmodel.AccountToID.ToString() + " amount: " + transactionmodel.TransactionAmount.ToString() + "\n" } ); db3.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Error1")); } } else { return(RedirectToAction("Error2")); } } return(RedirectToAction("Error")); }
public ActionResult Create(Admin _admin, HttpPostedFileBase PhotoPath2) { if (AdminSessionControl()) { if (ModelState.IsValid) { try { Password password = new Password(); int PasswordStatus = password.CheckStrength(_admin.Password); var Exist = db.Admins.Where(w => w.Email == _admin.Email).Count(); string PathAddress = ""; string PathAddress2 = ""; if (PhotoPath2 == null && PhotoPath2.ContentLength < 0) { ViewBag.Message = "Photo Not Acceptable"; //teacher.Password = ""; //teacher.ConfirmPassword = ""; return(View(PhotoPath2)); } else if (PasswordStatus < 4) { ViewBag.Message = "Password Not Strong"; return(View(PhotoPath2)); } else if (Exist > 0) { ViewBag.Message = "Email Address Has Already Existed"; _admin.Password = ""; _admin.ConfirmPassword = ""; return(View(_admin)); } else { RandomNumber _ran = new RandomNumber(); string Random = _ran.Random(10); //Photo Upload string _FileName = System.IO.Path.GetFileName(_admin.LastName + Random + PhotoPath2.FileName); PathAddress = Path.Combine(Server.MapPath("~/ShareFiles/Admins/"), _FileName); PathAddress2 = "ShareFiles/Admins/" + _FileName; PhotoPath2.SaveAs(PathAddress); //encript password here byte[] bytes = Encoding.Unicode.GetBytes(_admin.Password); byte[] inArray = HashAlgorithm.Create("SHA1").ComputeHash(bytes); _admin.Password = Convert.ToBase64String(inArray); _admin.ConfirmPassword = Convert.ToBase64String(inArray); _admin.PhotoPath = PathAddress2; db.Admins.Add(_admin); db.SaveChanges(); Mail _mail = new Mail(); // _mail.SendMail(teacher.Email, "Account Created From IIT System", "Dear Faculty Member greeting From IIT, This email is now registered to access IIT Course management System"); return(RedirectToAction("Index")); } } catch (Exception) { ViewBag.Message = "Something Wrong"; _admin.Password = ""; _admin.ConfirmPassword = ""; return(View(_admin)); } } ViewBag.Message = "Input Data not valide"; return(View(_admin)); } else { return(AdminLoginFaild()); } }