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;
 }
        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");
        }
 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"]);
 }
        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;
            }
        }