public static List <PresidentModel> GetPresident() { var presidentModelsList = new List <PresidentModel>(); var sessionFactory = SessionFactory.CreateSessionFactory(); using (var session = sessionFactory.OpenSession()) { using (session.BeginTransaction()) { var PresidentCreate = session.CreateCriteria(typeof(President)) .List <President>(); foreach (var con in PresidentCreate) { var temp = new PresidentModel() { Id = con.Id, Name = con.Name, Age = con.Age, }; presidentModelsList.Add(temp); } return(presidentModelsList); } } }
// GET: President public ActionResult Index() { if (RoleUser() == "User") { List <PresidentModel> List = new List <PresidentModel>(); foreach (var item in Ps.GetAll()) { PresidentModel Pm = new PresidentModel(); Pm.Id = item.Id; Pm.PresidentName = item.PresidentName; Pm.Email = item.Email; Pm.PhoneNumber = item.PhoneNumber; Pm.StreetName = item.StreetName; Pm.City = item.City; Pm.Logo = item.Logo; Pm.Photo = item.Photo; List.Add(Pm); } return(View(List)); } else { return(HttpNotFound()); } }
public ActionResult Edit(int id, PresidentModel Pm) { if (RoleUser() == "User") { President P = new President(); P = Ps.Get(t => t.Id == id); Pm.PresidentName = P.PresidentName; Pm.Email = P.Email; P.UserName = Pm.Email; Pm.PhoneNumber = P.PhoneNumber; Pm.StreetName = P.StreetName; Pm.City = P.City; Pm.Logo = P.Logo; Pm.Photo = P.Photo; Ps.Update(P); Ps.Commit(); return(RedirectToAction("Index")); } else { return(HttpNotFound()); } }
public NSObject CopyZithZone(IntPtr zone) { var copy = new PresidentModel { Name = this.Number, Age = this.Name }; Messaging.void_objc_msgSend(copy.Handle, selRetain); return copy; }
public ActionResult Delete(int id, PresidentModel Pm) { if (RoleUser() == "User") { President c = new President(); c = Ps.Get(t => t.Id == id); Ps.Delete(c); Ps.Commit(); return(RedirectToAction("Index")); } else { return(HttpNotFound()); } }
public ActionResult Create(PresidentModel Pm) { if (RoleUser() == "User") { President P = new President(); P.PresidentName = Pm.PresidentName; P.Email = Pm.Email; P.PhoneNumber = Pm.PhoneNumber; P.StreetName = Pm.StreetName; P.City = Pm.City; P.Logo = "Logo.jpg"; P.Photo = Pm.Photo; P.Role = "President"; var mp = RandomStringGenerator(); P.Password = mp; P.PasswordHash = _userManager.PasswordHasher.HashPassword(mp); P.LockoutEnabled = true; P.SecurityStamp = Guid.NewGuid().ToString(); /********Mail*****/ try { MailMessage message = new MailMessage("*****@*****.**", Pm.Email, "Hello", "Compte créé votre mail est : " + Pm.Email + ", Votre mp est: " + mp); message.IsBodyHtml = true; SmtpClient client = new SmtpClient("smtp.gmail.com", 587); client.EnableSsl = true; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "0720MB2326"); client.Send(message); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } /*********Mail***********/ Ps.Add(P); Ps.Commit(); return(RedirectToAction("index")); } else { return(HttpNotFound()); } }
public static List <PresidentModel> GetPresident() { var presidentModelsList = new List <PresidentModel>(); var sessionFactory = SessionFactory.CreateSessionFactory(); using (var session = sessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { if (save) { var country = new Country { Id = 1, Name = "Polska" }; session.SaveOrUpdate(country); transaction.Commit(); } var PresidentCreate = session.CreateCriteria(typeof(President)) .List <President>(); foreach (var con in PresidentCreate) { var temp = new PresidentModel() { Id = con.Id, Name = con.Name, Age = con.Age, }; presidentModelsList.Add(temp); } return(presidentModelsList); } } }
// GET: President/Details/5 public ActionResult Details(int id) { if (RoleUser() == "User") { President P = new President(); P = Ps.Get(t => t.Id == id); PresidentModel Pm = new PresidentModel(); Pm.Id = P.Id; Pm.PresidentName = P.PresidentName; Pm.Email = P.Email; Pm.PhoneNumber = P.PhoneNumber; Pm.StreetName = P.StreetName; Pm.City = P.City; Pm.Logo = P.Logo; Pm.Photo = P.Photo; return(View(Pm)); } else { return(HttpNotFound()); } }
public ActionResult ProfilePresident() { if (RoleUser() == "President") { President P = new President(); var id = Int32.Parse(User.Identity.GetUserId()); P = Ps.Get(t => t.Id == id); PresidentModel Pm = new PresidentModel(); Pm.Id = P.Id; Pm.PresidentName = P.PresidentName; Pm.Email = P.Email; Pm.PhoneNumber = P.PhoneNumber; Pm.StreetName = P.StreetName; Pm.City = P.City; Pm.Photo = P.Photo; Pm.Logo = P.Logo; return(View(Pm)); } else { return(HttpNotFound()); } }
public IEnumerable <PresidentModel> GetAllPresidents() { List <President> presidents = new List <President>(); List <PresidentModel> presidentsModel = new List <PresidentModel>(); presidents = _contentItemRepository.GetAllPresidents().ToList(); foreach (var item in presidents) { PresidentModel president = new PresidentModel { id = item.id, Name = item.name, Birthday = item.birthday, Birthplace = item.birthplace, Deathday = item.deathday, Deathplace = item.deathplace }; presidentsModel.Add(president); } return(presidentsModel); }