public static void NotificationAdd(int id) { FYPEntities db = new FYPEntities(); var grouplist = db.Student_Group.Where(p => p.Group_Id == id).FirstOrDefault(); for (int i = 0; i < 2; i++) { notification notif = new notification(); if (i == 0) { notif.N_To = grouplist.Student_1_ID; } if (i == 1) { notif.N_To = grouplist.Student_2_ID; } notif.Notification_Msg = "Your Request is Accepted By Advisor"; notif.Isread = false; notif.DateCreated = DateTime.Now; notif.is_active = true; FYPEntities dbs = new FYPEntities(); dbs.notifications.Add(notif); dbs.SaveChanges(); } }
// deleting rows action public ActionResult Delete(string[] ids) { // delete selected rows int[] id = null; if (ids != null) { id = new int[ids.Length]; int j = 0; foreach (string i in ids) { int.TryParse(i, out id[j++]); } } if (id != null && id.Length > 0) { List <VoteFinal> allSelected = new List <VoteFinal>(); FYPEntities db = new FYPEntities(); allSelected = db.VoteFinals.Where(x => id.Contains(x.Vid)).ToList(); foreach (var i in allSelected) { db.VoteFinals.Remove(i); } db.SaveChanges(); } return(RedirectToAction("List")); }
// GET: List //public ActionResult Index() //{ // return View(); //} // List action public ActionResult Index() { FYPEntities db = new FYPEntities(); List <VoteFinal> votefinal = new List <VoteFinal>(); votefinal = db.VoteFinals.ToList(); return(View(votefinal)); }
public ActionResult DeleteConfirmed(int id) { FYPEntities db = new FYPEntities(); var userDetails = db.Users.Find(id); db.Users.Remove(userDetails); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Index([Bind(Include = "Vid,Date,Email,VBitcoin,VEthereum,VBitcoinCash,VLitecoin,VRipple")] VoteFinal vote) { if (ModelState.IsValid) { using (FYPEntities db = new FYPEntities()) { db.VoteFinals.Add(vote); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View("Dash", "Dash")); }
public static void NotificationAdd(int id) { notification notif = new notification(); notif.N_To = id; notif.Notification_Msg = "Request Accepted"; notif.Isread = false; notif.DateCreated = DateTime.Now; notif.is_active = true; FYPEntities db = new FYPEntities(); db.notifications.Add(notif); db.SaveChanges(); }
public JsonResult AcceptRequest(int id) { int mystdid = Convert.ToInt32(Session["StudentId"]); var Stdreq = db.Student_Request.Where(p => p.Request_From_Id == id && p.Request_To_Id == mystdid).FirstOrDefault(); db.Dispose(); var std = new Student_Request() { ID = Stdreq.ID }; db = new FYPEntities(); db.Student_Request.Attach(std); std.Is_Active = false; std.Is_Accepted = true; std.Date_Accepeted = DateTime.Now; db.SaveChanges(); db.Dispose(); db = new FYPEntities(); group grp = new group(); grp.GroupName = "Group " + Stdreq.Request_From_Id + " --" + Stdreq.Request_To_Id; grp.Is_Active = true; grp.DateCreated = DateTime.Now; db.groups.Add(grp); db.SaveChanges(); int grpid = grp.Id; var stdgrp = new Student_Group(); stdgrp.Student_1_ID = Stdreq.Request_From_Id; stdgrp.Student_2_ID = Stdreq.Request_To_Id; stdgrp.Group_Id = grpid; db.Student_Group.Add(stdgrp); db.SaveChanges(); NotificationAdd(id); return(Json(new { success = true, msg = "Successfully sent" }, JsonRequestBehavior.AllowGet)); }
public ActionResult Authorize(User userModel) { using (FYPEntities db = new FYPEntities()) { var userDetails = db.Users.Where(x => x.Username == userModel.Username && x.Password == userModel.Password).FirstOrDefault(); if (userDetails == null) { userModel.LoginErrorMessage = "Wrong username or password."; return(View("Index", userModel)); } else { Session["userID"] = userDetails.Id; Session["userName"] = userDetails.Username; Session["role"] = userDetails.Role; return(RedirectToAction("Index", "Home")); } } }
public ActionResult AddOrEdit(User userModel) { using (FYPEntities db = new FYPEntities()) { if (db.Users.Any(x => x.Username == userModel.Username)) { ViewBag.DuplicationMessage = "User already exist!"; return(View("AddOrEdit", userModel)); } db.Users.Add(userModel); db.SaveChanges(); } string fromaddr = "*****@*****.**"; string toaddr = userModel.Email;//TO ADDRESS HERE string password = "******"; MailMessage msg = new MailMessage(); msg.Subject = "Account Created"; msg.From = new MailAddress(fromaddr); msg.Body = "Username: "******"\nPassword: "******"smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = false; smtp.EnableSsl = true; NetworkCredential nc = new NetworkCredential(fromaddr, password); smtp.Credentials = nc; smtp.Send(msg); ModelState.Clear(); ViewBag.SuccessMessage = "Registration Successful!"; return(View("AddOrEdit", new User())); }
public JsonResult AcceptstudentRequest(int id) { int advisorid = Convert.ToInt32(Session["AdvisorId"]); var adv = db.Advisors.Where(p => p.Id == advisorid).FirstOrDefault(); int slots = Convert.ToInt32(adv.Advisors_Slot); if (slots > 0 && CheckStudentAdvisorGroup(id) == false) { var stdadvreq = new Student_Advisor_Request() { Id = id }; db.Student_Advisor_Request.Attach(stdadvreq); stdadvreq.Is_Accepted = true; stdadvreq.Date_Accepted = DateTime.Now; stdadvreq.Is_Active = false; db.SaveChanges(); db.Dispose(); db = new FYPEntities(); var advisorslotupdate = new Advisor() { Id = advisorid }; db.Advisors.Attach(advisorslotupdate); advisorslotupdate.Advisors_Slot = slots - 1; db.SaveChanges(); NotificationAdd(id); return(Json(new { msg = "Successfull", success = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { msg = "Unable To Accept 0 Slots Available or Student Already in Group", success = true }, JsonRequestBehavior.AllowGet)); } }
public String CheckCountry() { Column col = new Column(); string loc1 = "rathgama"; string loc2 = "London"; string loc6 = "Dublin"; string loc3 = "Paris"; string loc4 = "NY"; string loc5 = "Rathnapura"; col.Data = new List <string>(); col.Data.Add(loc6); col.Data.Add(loc2); col.Data.Add(loc1); int rowCount = col.Data.Count; string[] jsonResponse = new string[rowCount]; /* * for (int i = 0; i < rowCount; i++) * { * string address = col.Data[i]; * string url = "https://maps.googleapis.com/maps/api/geocode/json?address=" + address + "&key=AIzaSyBe7bmv5rusSTJ__tPpPoNkCUt0rxjR7jo"; * var request = (HttpWebRequest)WebRequest.Create(url); * * var response = (HttpWebResponse)request.GetResponse(); * * var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); * jsonResponse[i] = responseString; * } */ //jsonResponse[0]="{ \"results" : [{\"address_components\" : [{\"long_name\" : \"Rathgama\",\"short_name\" : \"Rathgama\", \"types\" : [ \"locality\", \"political\" ]},{\"long_name\" : \"Galle\", \"short_name\" : \"Galle\", \"types\" : [ \"administrative_area_level_2\", \"political\" ]}, { \"long_name\" : \"Southern Province\", \"short_name\" : \"SP\", \"types\" : [ \"administrative_area_level_1\", \"political\" ]}, { \"long_name\" : \"Sri Lanka\", \"short_name\" : \"LK\", \"types\" : [ \"country\", "political" ] } ], "formatted_address" : "Rathgama, Sri Lanka", "geometry" : { "bounds" : { "northeast" : { "lat" : 6.0994063, "lng" : 80.15857869999999 }, "southwest" : { "lat" : 6.085765599999999, "lng" : 80.1325178} }, "location" : { "lat" : 6.0936187, "lng" : 80.14305419999999},"location_type" : "APPROXIMATE", "viewport" : {"northeast" : { "lat" : 6.0994063, "lng" : 80.15857869999999 },"southwest" : { "lat" : 6.085765599999999, "lng" : 80.1325178 } } }, "place_id" : "ChIJc73LoPd24ToRpNTaC290rk0", "types" : [ "locality", "political" ] } ], "status" : "OK"}" int arrayEntryCount = 0; var locationHeirarchy = new Dictionary <int, string>(); string countryList = ""; foreach (var val in jsonResponse) { arrayEntryCount++; dynamic jsonResult = JsonConvert.DeserializeObject(val); string resultStatus = jsonResult.status; if (resultStatus == "OK") { //LocationCount++; AddressComponents[] address = jsonResult.results[0].address_components.ToObject <AddressComponents[]>(); countryList += address[address.Length - 1].long_name; countryList += ","; } } FYPEntities entity = new FYPEntities(); var regionParameter = new ObjectParameter("region", typeof(string)); var resolutionParameter = new ObjectParameter("resolution", typeof(string)); entity.getRegionCodeAndResolution(countryList, regionParameter, resolutionParameter); return(regionParameter.Value.ToString() + " " + resolutionParameter.Value.ToString()); }
public ActionResult AcceptRequests(int id) { var user = new User { Id = id }; //db.sp_Accept_SignUp(id); db.Users.Attach(user); try { user.Is_Active = true; user.Is_Pending = false; user.Status = "Active"; db.SaveChanges(); db.Dispose(); notification notifc = new notification(); notifc.Notification_Msg = "Your Sign Up Request Is Accepted"; notifc.N_To = id; // NotificationAdd(id); } 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); } } throw; } db = new FYPEntities(); var usr = db.Users.Where(p => p.Id == id).FirstOrDefault(); if (usr.Is_Student == true) { //student data update in students table int stdid = Convert.ToInt32(usr.Std_Adv_Id); var student = new Student() { ID = stdid }; db.Students.Attach(student); student.IsPending = false; student.IsActive = true; db.SaveChanges(); //student data update in user in roles table var roles = db.Roles.Where(p => p.Role_Name == "Student").FirstOrDefault(); User_IN_Roles uir = new User_IN_Roles(); uir.Role_Id = roles.Id; uir.User_Id = id; uir.Is_Active = true; uir.Status = "Active"; uir.Date_Created = DateTime.Now; uir.Created_By = 1; db.User_IN_Roles.Add(uir); db.SaveChanges(); } else { //advisor data update in students table int advid = Convert.ToInt32(usr.Std_Adv_Id); var advisor = new Advisor() { Id = advid }; db.Advisors.Attach(advisor); advisor.IsBlock = false; advisor.IsActive = true; db.SaveChanges(); //student data update in user in roles table var roles = db.Roles.Where(p => p.Role_Name == "Advisor").FirstOrDefault(); User_IN_Roles uir = new User_IN_Roles(); uir.Role_Id = roles.Id; uir.User_Id = id; uir.Is_Active = true; uir.Status = "Active"; uir.Date_Created = DateTime.Now; uir.Created_By = 1; db.User_IN_Roles.Add(uir); db.SaveChanges(); } return(RedirectToAction("AcceptSignUp", "Admin")); }
public ActionResult Index() { FYPEntities db = new FYPEntities(); return(View(db.Users.ToList())); }