public ActionResult AddPerson(int?add) { IEnumerable <RequestContactList> req = from s in db.RequestContactList where s.OwnerId == userid && s.ContactId == (int)add select s; try { if (req.First() == null && add != null) { TempData["requestmessage"] = "You have already sent request. "; return(Redirect(Request.Url.ToString())); } } catch { using (DiabetEntities db = new DiabetEntities()) { RequestContactList newrequest = new RequestContactList(); newrequest.OwnerId = (int)userid; newrequest.status = 0; newrequest.ContactId = (int)add; db.RequestContactList.Add(newrequest); db.SaveChanges(); return(Redirect(Request.UrlReferrer.ToString())); } } return(Redirect(Request.UrlReferrer.ToString())); }
public ActionResult RegisterPatient() { List <SelectListItem> lst = new List <SelectListItem>(); List <SelectListItem> lst2 = new List <SelectListItem>(); using (DiabetEntities context = new DiabetEntities()) { List <Parameter> lstP = context.Parameter.ToList(); foreach (Parameter item in lstP) { SelectListItem sItem = new SelectListItem() { Text = item.GroupName, Value = item.GroupCode.ToString() }; lst.Add(sItem); } SelectListItem sItem2 = new SelectListItem() { Text = "Yes", Value = "Yes" }; SelectListItem sItem3 = new SelectListItem() { Text = "No", Value = "No" }; lst2.Add(sItem2); lst2.Add(sItem3); ViewBag.GetGender = new SelectList((List <SelectListItem>)lst, "Value", "Text"); ViewBag.GetInsulin = new SelectList((List <SelectListItem>)lst2, "Value", "Text"); return(View()); } }
public ActionResult Messages(int id) { //int si = 8; //id = 6; IEnumerable <Message> messages = from s in db.Message where s.UserId == id && s.SenderId == (int)userid || s.SenderId == id && s.UserId == (int)userid select s; if (messages.Count() >= 1) { messages.ToList().ForEach(u => { u.IsRead = 1; }); db.SaveChanges(); return(PartialView(messages)); } else { using (DiabetEntities db = new DiabetEntities()) { Message newmessage = new Message(); newmessage.UserId = (int)userid; newmessage.SenderId = (int)id; newmessage.MessageLength = "You are now connected. You can write a message"; newmessage.MessageDate = DateTime.Now; db.Message.Add(newmessage); db.SaveChanges(); } IEnumerable <Message> messages2 = from s in db.Message where s.UserId == id && s.SenderId == (int)userid || s.SenderId == id && s.UserId == (int)userid select s; return(PartialView(messages2)); } }
public ActionResult AddDietList2([Bind(Include = "DietListContent,MaxAge,MinAge,MaxBMI,MinBMI,Gender,InsulingUsage")] DietList model) { if (AddDietListID == null) { return(RedirectToAction("AddDietList", "Experts")); } if (userid == null) { return(RedirectToAction("AddDietList", "Experts")); } if (model.MaxAge == null) { return(RedirectToAction("AddDietList", "Experts")); } else { using (DiabetEntities db = new DiabetEntities()) { DietList dietList = new DietList(); dietList.DietListContent = model.DietListContent; dietList.DietListDate = DateTime.Now; dietList.Gender = model.Gender; dietList.GivenFromId = (int)userid; dietList.GiveToId = (int)AddDietListID; dietList.MaxAge = model.MaxAge; dietList.MinAge = model.MinAge; dietList.MinBMI = model.MinBMI; dietList.MaxBMI = model.MaxBMI; dietList.InsulingUsage = model.InsulingUsage; db.DietList.Add(dietList); db.SaveChanges(); return(RedirectToAction("Index", "Experts", new { id = userid })); } } }
public ActionResult AddDietList2(int?id) { //if (add == null) //{ // return RedirectToAction("AddDietList","Experts"); //} //else //{ IEnumerable <Login> login = from t in db.Login where t.UserId == userid select t; AddDietListID = (int)id; List <SelectListItem> lst = new List <SelectListItem>(); List <SelectListItem> lst2 = new List <SelectListItem>(); using (DiabetEntities context = new DiabetEntities()) { List <Parameter> lstP = context.Parameter.ToList(); foreach (Parameter item in lstP) { SelectListItem sItem = new SelectListItem() { Text = item.GroupName, Value = item.GroupCode.ToString() }; lst.Add(sItem); } DiabetEntities db = new DiabetEntities(); DietList dietList = new DietList(); SelectListItem sItem2 = new SelectListItem() { Text = "Yes", Value = "Yes" }; SelectListItem sItem3 = new SelectListItem() { Text = "No", Value = "No" }; lst2.Add(sItem2); lst2.Add(sItem3); ViewBag.GetGender = new SelectList((List <SelectListItem>)lst, "Value", "Text"); ViewBag.GetInsulin = new SelectList((List <SelectListItem>)lst2, "Value", "Text"); var tuple = new Tuple <Login, DietList>(login.First(), dietList); return(View(dietList)); //} } }
public ActionResult Accept(int?id) { if (id != null) { using (DiabetEntities db = new DiabetEntities()) { IEnumerable <Login> logins = from s in db.Login where s.UserId == id select s; logins.Single().TypeApproval = logins.Single().UserDetail.Type; db.SaveChanges(); return(RedirectToAction("Index", "Admin")); } } else { return(RedirectToAction("Index", "Admin")); } }
public ViewResult Index(MVCExample.Models.MailModel _objModelMail) { using (DiabetEntities db = new DiabetEntities()) { RecoverAccount2 rcv = new RecoverAccount2(); IEnumerable <UserDetail> email = from s in db.UserDetail where s.Mail == _objModelMail.To select s; if (email != null) { if (ModelState.IsValid) { MailMessage mail = new MailMessage(); mail.To.Add(_objModelMail.To); mail.From = new MailAddress("*****@*****.**"); mail.Subject = "Account Recovery"; string Body = _objModelMail.Body; Random rand = new Random(DateTime.Now.Millisecond); int random = rand.Next(); mail.Body = "<a href=\"http://*****:*****@gmail.com", "gozdefurkan"); // Enter seders User name and password smtp.EnableSsl = true; smtp.Send(mail); return(View("Index", _objModelMail)); } else { return(View()); } } else { return(View()); } } }
public ActionResult Recover(MVCExample.Models.Login login) { long key2 = long.Parse(key); using (DiabetEntities db = new DiabetEntities()) { RecoverAccount2 usermail = db.RecoverAccount2.Find(key2); string hashedpassword = ComputeHash(login.Password); usermail.UserDetail.Password = hashedpassword; //IEnumerable <string> users = from s in db.UserDetail where s.Mail == usermail.Email.First().ToString() select s.Username.ToString(); //IEnumerable<Login> logins = from l in db.Login where l.Username == users.First() select l; //int idd =( int) logins.First().UserId; //Login diet = db.Login.Find(idd); //diet.Password = login.Password; db.SaveChanges(); return(RedirectToAction("Index", "Login")); } }
public ActionResult AddBloodSugarLevel(int?level) { using (DiabetEntities db = new DiabetEntities()) { AddBloodSugar bsl = new AddBloodSugar(); bsl.UserId = (int)userid; if (level != null) { bsl.BloodSugarValue = (int)level; } else { return(Redirect(Request.UrlReferrer.ToString())); } bsl.BloodSugarEntranceDate = DateTime.Now; db.AddBloodSugar.Add(bsl); db.SaveChanges(); } return(Redirect(Request.UrlReferrer.ToString())); }
public ActionResult AddMessage(int id1, int id2, string typedmessage) { using (DiabetEntities db = new DiabetEntities()) { Message newmessage = new Message(); if (userid == id1) { newmessage.UserId = (int)id1; newmessage.SenderId = (int)id2; } else if (userid == id2) { newmessage.UserId = (int)id2; newmessage.SenderId = (int)id1; } else { return(RedirectToAction("Index", "Home")); } if (typedmessage.Length < 400 && typedmessage.Length > 1) { newmessage.MessageLength = typedmessage; } else { return(Redirect(Request.UrlReferrer.ToString())); } newmessage.MessageDate = DateTime.Now; newmessage.IsRead = 0; db.Message.Add(newmessage); db.SaveChanges(); } return(Redirect(Request.UrlReferrer.ToString())); }
// GET: Admin public ActionResult Index(int?id) { if (id != null) { DiabetEntities db = new DiabetEntities(); IEnumerable <Login> isadmin = from k in db.Login where k.UserId == id select k; if (isadmin.First().Username == "admin") { IEnumerable <Login> logins = from s in db.Login where s.TypeApproval == 0 select s; return(View(logins)); } else { return(RedirectToAction("Index", "Login")); } } else { return(RedirectToAction("Index", "Login")); } }
public ActionResult RegisterDietitian() { List <SelectListItem> lst = new List <SelectListItem>(); using (DiabetEntities context = new DiabetEntities()) { List <Parameter> lstP = context.Parameter.ToList(); foreach (Parameter item in lstP) { SelectListItem sItem = new SelectListItem() { Text = item.GroupName, Value = item.GroupCode.ToString() }; lst.Add(sItem); } ViewBag.GetGender = new SelectList((List <SelectListItem>)lst, "Value", "Text"); return(View()); } }
public ActionResult Index(Login model, string Command) { if (Command == "Giris") { try { using (DiabetEntities db = new DiabetEntities()) { string hashpassword = ComputeHash(model.Password); var context = db.Login.Where(s => s.Username == model.Username && s.Password == hashpassword); var emailReq = context.FirstOrDefault <Login>(); var id = emailReq.UserId; var approval = emailReq.TypeApproval; if (emailReq != null && approval != 0) { int?id2 = id; HttpCookie cookie = new HttpCookie("userid", id2.ToString()); cookie.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(cookie); if (approval == 1) { return(RedirectToAction("Index", "Home", new { id })); } else if (approval == 2 || approval == 3) { return(RedirectToAction("Index", "Experts", new { id })); } else if (approval == 4) { return(RedirectToAction("Index", "Admin", new { id })); } } else if (emailReq == null) { // "Kullanıcı adı ve şifre hatalıdır" diye gösterilecek TempData["message"] = "Username or Password is not correct"; return(View()); } else { TempData["message"] = "Wait for the approval. "; return(View()); } } } catch (Exception) { TempData["message"] = "Username or Password is not correct"; } } if (Command == "KayitOl") { return(RedirectToAction(controllerName: "Login", actionName: "Type")); } return(View()); }
public ActionResult RegisterDietitian(UserDetail model, HttpPostedFileBase file) { string path1 = ""; string extension2 = ""; try { if (file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var extension = Path.GetExtension(file.FileName); extension2 = extension; Random rand = new Random(DateTime.Now.Millisecond); int fname = rand.Next(); var path = Path.Combine(Server.MapPath("~/Files"), fname.ToString() + extension2); file.SaveAs(path); path1 = path; } } catch { } //string hPassword = ComputeHash(model.Password, new SHA256CryptoServiceProvider()); using (DiabetEntities db = new DiabetEntities()) { try { string typpeeid = RouteData.Values["id"].ToString(); UserDetail _userDetail = new UserDetail(); _userDetail.Type = int.Parse(typpeeid); string hashpassword = ComputeHash(model.Password); _userDetail.Password = hashpassword; _userDetail.Name = model.Name; _userDetail.Username = model.Username; _userDetail.Surname = model.Surname; _userDetail.Mail = model.Mail; _userDetail.PhoneNumber = model.PhoneNumber; _userDetail.ShortCV = model.ShortCV; _userDetail.ProfilePictureURL = "/Content/dist/img/avatar.png"; _userDetail.FileLink = "/Files/" + Path.GetFileName(path1); db.UserDetail.Add(_userDetail); db.SaveChanges(); int? id = _userDetail.UserId; Login _login = new Login(); _login.Username = model.Username; _login.Password = hashpassword; _login.UserId = id; _login.TypeApproval = 0; db.Entry(_login).State = EntityState.Added; db.SaveChanges(); } catch (Exception) { TempData["errormessage"] = "Check inputs."; } } List <SelectListItem> lst = new List <SelectListItem>(); using (DiabetEntities context = new DiabetEntities()) { List <Parameter> lstP = context.Parameter.ToList(); foreach (Parameter item in lstP) { SelectListItem sItem = new SelectListItem() { Text = item.GroupName, Value = item.GroupCode.ToString() }; lst.Add(sItem); } ViewBag.GetGender = new SelectList((List <SelectListItem>)lst, "Value", "Text"); return(RedirectToAction("RegisterDietitian")); } }