コード例 #1
0
 public bool IsAdmin(Admin admin)
 {
     Admin temp = entities.Admins.FirstOrDefault(x => x.Email.Equals(admin.Email) && x.Pasword.Equals(admin.Pasword));
     if(temp != null)
         return true;
     return false;
 }
コード例 #2
0
        public ActionResult Login(Admin admin)
        {
            Admin temp = _adminRepositiry.GetAdmin(admin.Email);
            if (_adminRepositiry.IsAdmin(admin) && temp != null)
            {
                Session["admin"] = temp;
                Session.Timeout = 30;
            }

            else
            {
                ViewBag.isAdmin = false;
                return RedirectToAction("Login");
            }

            return RedirectToAction("Index");
        }
コード例 #3
0
 public ActionResult EditProfile(Admin a)
 {
     if (Session["admin"] == null)
         return RedirectToAction("Login", "Admin");
     try
     {
         HttpPostedFileBase file = Request.Files[0];
         if (file != null && file.ContentLength > 0)
         {
             string path = Server.MapPath("~/UserUploads/Admin/" + file.FileName);
             file.SaveAs(path);
             a.ProfileImage = file.FileName;
         }
     }
     catch
     {
         
     }
     
     _adminRepositiry.EditProfile(a);
     Session["admin"] = _adminRepositiry.GetAdmin(a.Id);
     return View("AdminProfile",Session["admin"]);
 }
コード例 #4
0
        public bool EditProfile(Admin a)
        {

            try
            {
                Admin temp = entities.Admins.FirstOrDefault(x => x.Id == a.Id);
                if(!string.IsNullOrEmpty(a.Email))
                    temp.Email = a.Email;
                if(!string.IsNullOrEmpty(a.Name))
                    temp.Name = a.Name;
                if(!string.IsNullOrEmpty(a.Pasword))
                    temp.Pasword = a.Pasword;
                if(!string.IsNullOrEmpty(a.ProfileImage))
                    temp.ProfileImage = a.ProfileImage;

                entities.Entry(temp).State = EntityState.Modified;
                entities.SaveChanges();
                return true;
            }
            catch (Exception exception)
            {
                return false;
            }
        }