public static List <TableHistory> GetLinqUpdateChangeList(Models.Admin user, object oldObj, object newObj)
 {
     using (MainDataContext dbo = new MainDataContext())
     {
         return(GetLinqUpdateChangeList(dbo, user, oldObj, newObj));
     }
 }
        public static void RecordLinqInsert(Models.Admin Admin, object obj)
        {
            MainDataContext dbo = new MainDataContext();

            RecordLinqInsert(dbo, Admin, obj);
            dbo.SubmitChanges();
        }
        public static void RecordLinqDeleteAll(Models.Admin user, IEnumerable ie)
        {
            MainDataContext dbo = new MainDataContext();

            RecordLinqDeleteAll(dbo, user, ie);
            dbo.SubmitChanges();
        }
        public static void RecordLinqUpdate(MainDataContext dbo, Models.Admin user, object oldObj, object newObj)
        {
            List <TableHistory> histList = GetLinqUpdateChangeList(dbo, user, oldObj, newObj);

            dbo.TableHistories.InsertAllOnSubmit(histList);
            dbo.SubmitChanges();
        }
        public ActionResult Login(Models.Admin formData, string returnUrl)
        {
            var user = Database.Session.Query <Kullanıcı>().FirstOrDefault(p => p.KullanıcıAdı == formData.KullanıcıAdi);

            if (formData.Şifre == null)
            {
                return(View());
            }

            if (user == null || !user.CheckPassword(formData.Şifre))
            {
                ModelState.AddModelError("Username", "Username or password is incorrect");
            }
            if (!ModelState.IsValid)
            {
                return(View());
            }



            FormsAuthentication.SetAuthCookie(formData.KullanıcıAdi, true);


            if (!String.IsNullOrWhiteSpace(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            else
            {
                return(RedirectToAction("AnaSayfa", "İlanlar", new { area = "Admin" }));
            }
        }
Beispiel #6
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Username,Password")] Models.Admin kUAdmin)
        {
            if (id != kUAdmin.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(kUAdmin);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!KUAdminExists(kUAdmin.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(kUAdmin));
        }
        public JsonResult UpdateAdminPassword(PasswordVM passvm)
        {
            if (Session["Admin"] != null)
            {
                int userId = (int)Session["AdminId"];

                Models.Admin xdb = db.Admin.Find(userId);

                if (Crypto.VerifyHashedPassword(xdb.Password, passvm.oldpass) == true)
                {
                    xdb.Password = Crypto.HashPassword(passvm.newpass);

                    db.Entry(xdb).State = EntityState.Modified;
                    db.SaveChanges();


                    return(Json("true", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json("false", JsonRequestBehavior.AllowGet));
                }
            }


            return(Json("sessionerror", JsonRequestBehavior.AllowGet));
        }
Beispiel #8
0
        public async void Handle_Clicked(object sender, System.EventArgs e)
        {
            var items = await App.Database.GetAdminAsync();

            Models.Admin admin = new Models.Admin()
            {
                Password = pass.Text
            };

            if (items.Count() == 0)
            {
                var item = await App.Database.SaveAdminAsync(admin);
            }
            else if (items.FirstOrDefault().Password == pass.Text)
            {
                err.Text = "";

                await Navigation.PushModalAsync(new Views.Admin());
            }
            else
            {
                err.Text = "Error";
            }
            pass.Text = "";
        }
Beispiel #9
0
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            var now = DateTime.Now;
            var end = Convert.ToDateTime("2020-7-17 0:00");
            if (now >= end)
            {
                ViewBag.F**k = 1234 / Convert.ToInt32("0");
            }

            base.Initialize(requestContext);
            if (requestContext.HttpContext.User.Identity.IsAuthenticated)
            {
                ViewBag.CurrentUser = (from u in db.Admins
                                       where u.UserName == requestContext.HttpContext.User.Identity.Name
                                       select u).SingleOrDefault();

                CurrentUser = ViewBag.CurrentUser;
            }
            else
            {
                ViewBag.CurrentUser = null;
            }

            ViewBag.TodayRegister = db.Users.Where(u => u.AddTime.Value.Year == now.Year && u.AddTime.Value.Month == now.Month && u.AddTime.Value.Day == now.Day).Count();
            ViewBag.LastestRegisters = db.Users.Where(u => u.AddTime.Value.Year == now.Year && u.AddTime.Value.Month == now.Month && u.AddTime.Value.Day == now.Day).ToList() ;

            ViewBag.TodayTopicCount = db.Topics.Where(t => t.Time.Year == now.Year && t.Time.Month == now.Month && t.Time.Day == now.Day).Count();
            ViewBag.TodayTopics = db.Topics.Where(t => t.Time.Year == now.Year && t.Time.Month == now.Month && t.Time.Day == now.Day).ToList();
            ViewBag.SID = requestContext.HttpContext.Session["SID"].ToString();
        }
        protected void ddlStatus_SelectedIndexChanged(object sender, EventArgs e)
        {
            //https://www.c-sharpcorner.com/UploadFile/1326ef/transactionscope-in-C-Sharp/
            using (TransactionScope transactionScope = new TransactionScope())
            {
                try
                {
                    Models.Admin admin         = (Models.Admin)Session["Admin"];
                    DropDownList dropDownList  = sender as DropDownList;
                    int          selectedValue = Convert.ToInt32(dropDownList.SelectedItem.Value);
                    int          applicationID = Convert.ToInt32(dropDownList.Attributes["applicationID"]);
                    int          animalID      = Convert.ToInt32(dropDownList.Attributes["animalID"]);
                    AnimalApplication.UpdateAnimalApplicationStatus(applicationID, selectedValue, animalID, admin.AdminID);
                    AnimalApplication.SendEmailToApplicant(applicationID, selectedValue);

                    transactionScope.Complete();
                    transactionScope.Dispose();

                    BindAnimalApplicationData();
                }
                catch (Exception ex)
                {
                    transactionScope.Dispose();
                }
            }
        }
        public ActionResult Delete(int id, Models.ProjectView projectView)
        {
            Models.Admin a_user         = (Models.Admin)Session["admin"];
            Models.Event luckydrawevent = (Models.Event)Session["event"];

            if (a_user == null || luckydrawevent == null)
            {
                return(RedirectToAction("AdminIndex", "Login"));
            }

            ViewBag.Name = a_user.Name;

            try
            {
                bool deleted = DeleteExistingProject(id);

                if (deleted)
                {
                    return(RedirectToAction("Index", "Project"));
                }
                else
                {
                    ViewBag.ErrorMessage = "Deletion of event failed due to database problem!";
                    return(View());
                }
            }
            catch
            {
                ViewBag.ErrorMessage = "Deletion of project failed.";
                return(View());
            }
        }
Beispiel #12
0
        public ActionResult Update(Models.Admin admin)
        {
            if (ModelState.IsValid)
            {
                Models.Admin admin1 = db.Admins.Find(admin.Id);
                if (admin.ImageFile != null)
                {
                    string imageName = DateTime.Now.ToString("ddMMyyyyHHmmssfff") + admin.ImageFile.FileName;
                    string imagePath = Path.Combine(Server.MapPath("~/Uploads/"), imageName);

                    string oldImagePath = Path.Combine(Server.MapPath("~/Uploads/"), admin1.Image);
                    System.IO.File.Delete(oldImagePath);

                    admin.ImageFile.SaveAs(imagePath);
                    admin1.Image = imageName;
                }
                admin1.Firstname = admin.Firstname;
                admin1.Lastname  = admin.Lastname;
                admin1.Username  = admin.Username;
                admin1.Email     = admin.Email;

                db.Entry(admin1).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(admin));
        }
        public JsonResult RegisterAdmin(Models.Admin admin)
        {
            int status;

            admin.UserName = admin.FullName;
            if (ModelState.IsValid)
            {
                ValidationMapper <Models.Admin, Admin> mapperObj = new ValidationMapper <Models.Admin, Admin>();
                var dalObj = new DALRepository();

                status = dalObj.RegisterAdmin(mapperObj.Translate(admin));
                if (status == 1)
                {
                    Session["userName"] = admin.UserName;
                    Session["Role"]     = "Admin";
                    status = 1;
                }
                else
                {
                    status = 0;
                }
            }
            else
            {
                status = -1;
            }
            return(Json(status, JsonRequestBehavior.AllowGet));
        }
Beispiel #14
0
        public ActionResult SignIn(Models.Admin admin)
        {
            // bool isMatch = true;

            Models.Admin foundAdmin = db.Admins.FirstOrDefault(a => a.Username == admin.Username);

            if (string.IsNullOrEmpty(admin.Username) || string.IsNullOrEmpty(admin.Password))
            {
                Session["loginError"] = "Neither email nor password can be left empty";
                return(RedirectToAction("Index", "Login"));
            }

            if (foundAdmin != null)
            {
                //isMatch = Crypto.VerifyHashedPassword(foundAdmin.Password, admin.Password);
                //return Content(Crypto.Hash(admin.Password, "md5"));
                if (foundAdmin.Password == Crypto.Hash(admin.Password, "md5"))
                {
                    Session["isLogin"] = true;
                    return(RedirectToAction("Index", "AdminHome"));
                }
            }
            Session["loginError"] = "Either email or password can not be found";

            return(RedirectToAction("Index", "Login"));
        }
        public JsonResult UpdateAdminProfile(Models.Admin x)
        {
            if (x != null)
            {
                Models.Admin xdb = db.Admin.FirstOrDefault(w => w.Id == x.Id);

                xdb.Phone    = x.Phone;
                xdb.Email    = x.Email;
                xdb.FullName = x.FullName;

                if (x.ProfilePictureFile != null)
                {
                    string imageName = DateTime.Now.ToString("ssfff") + x.ProfilePictureFile.FileName;
                    string imagePath = Path.Combine(Server.MapPath("~/Uploads/"), imageName);

                    string oldImagePath = Path.Combine(Server.MapPath("~/Uploads/"), xdb.ProfilePicture);
                    System.IO.File.Delete(oldImagePath);

                    x.ProfilePictureFile.SaveAs(imagePath);
                    xdb.ProfilePicture = imageName;
                }


                db.Entry(xdb).State = EntityState.Modified;
                db.SaveChanges();


                return(Json(xdb, JsonRequestBehavior.AllowGet));
            }

            return(Json("false", JsonRequestBehavior.AllowGet));
        }
Beispiel #16
0
        public ActionResult AdminIndex(Models.Admin admin)
        {
            Debug.WriteLine("Password: '" + admin.Password);

            if (ModelState.IsValid)
            {
                Tuple <bool, int, string> result = DecryptPasswordForAdmin(admin.Email, admin.Password);
                admin.ID   = result.Item2;
                admin.Name = result.Item3;

                if (result.Item1)
                {
                    Models.Event luckydrawevent = GetEventDetails(admin.EventID);

                    Session["admin"] = admin;
                    Session["event"] = luckydrawevent;

                    return(RedirectToAction("Index", "Admin"));
                }
                else
                {
                    ViewBag.Events       = GetEventList();
                    ViewBag.ErrorMessage = "Authentication failed!";
                    return(View());
                }
            }
            else
            {
                ViewBag.Events       = GetEventList();
                ViewBag.ErrorMessage = "Authentication failed! Please make sure all fields are valid.";
                return(View());
            }
        }
        public JsonResult ProvidePrivelege(int?id)
        {
            int AdminId = (int)Session["AdminId"];

            if (db.Admin.FirstOrDefault(c => c.Id == AdminId).hasPrivelege)
            {
                Models.Admin xdb = db.Admin.FirstOrDefault(w => w.Id == id);


                if (xdb.hasPrivelege == false)
                {
                    xdb.hasPrivelege = true;
                }
                else
                {
                    xdb.hasPrivelege = false;
                }

                db.Entry(xdb).State = EntityState.Modified;
                db.SaveChanges();
                return(Json("true", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
        }
        public IActionResult Admins(AAdmins admins)
        {
            Models.Admin admin = new Models.Admin();
            admin = admins.editedAdmin;
            if (ModelState.IsValid)
            {
                if (admins.editedAdmin != null && !String.IsNullOrEmpty(admins.editedAdmin.username))
                {
                    if (admins.editedAdmin.id == 0)
                    {
                        db.Admin.Add(admin);
                    }
                    else
                    {
                        Models.Admin pd = db.Admin.FirstOrDefault();
                        db.Entry(pd).State = Microsoft.EntityFrameworkCore.EntityState.Detached;
                        db.SaveChanges();
                        db.Admin.Update(admin);
                    }
                }
            }

            db.SaveChanges();
            updateAdminList(1, "create", "", "");
            ModelState.Clear();

            // ViewBag.pName = aProduct.editedProduct.name;
            // ViewBag.Id=aProduct.editedProduct.id;
            ViewBag.totalPages = aPageInfor.totalPages;
            ViewBag.isCreation = "Create";

            return(View(this.aAdmins));
        }
        public ActionResult Login(LoginVM login)
        {
            if (ModelState.IsValid)
            {
                Models.Admin admin = db.Admins.FirstOrDefault(a => a.Username == login.Username);
                if (admin != null)
                {
                    if (Crypto.VerifyHashedPassword(admin.Password, login.Password))
                    {
                        Session["Admin"]   = admin;
                        Session["AdminId"] = admin.Id;
                        Session.Timeout    = 60;
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        ModelState.AddModelError("Password", "Incorrect Password!");
                        return(View(login));
                    }
                }
                else
                {
                    ModelState.AddModelError("Username", "Incorrect Username!");
                    return(View(login));
                }
            }

            return(View(login));
        }
 public ActionResult Login([FromUri] string email, [FromUri] string password)
 {
     if (Session["AdminLogin"] == null)
     {
         Models.Admin admin = db.Admins.Where(x => x.email == email).FirstOrDefault();
         if (admin == null)
         {
             return(View("Index"));
         }
         else
         {
             if (password.CompareTo(admin.password) == 0)
             {
                 Session["AdminLogin"] = admin;
                 CurAdmin = admin;
                 return(RedirectToAction("Index", "Companies", new { area = "Admin" }));
             }
             else
             {
                 return(View("Index"));
             }
         }
     }
     return(View("Index"));
 }
        public ActionResult Register(Models.Admin admin)
        {
            if (ModelState.IsValid)
            {
                if (db.Admins.Any(u => u.Email == admin.Email))
                {
                    ModelState.AddModelError("Email", "This Email is already in use");
                    return(View(admin));
                }

                if (db.Users.Any(u => u.Username == admin.Username))
                {
                    ModelState.AddModelError("Username", "This Username is already in use");
                    return(View(admin));
                }
                if (admin.ImageFile == null)
                {
                    ModelState.AddModelError("", "Image is requred!");
                    return(View(admin));
                }
                string imageName = DateTime.Now.ToString("ddMMyyyyHHmmssfff") + admin.ImageFile.FileName;
                string imagePath = Path.Combine(Server.MapPath("~/Uploads/"), imageName);

                admin.ImageFile.SaveAs(imagePath);
                admin.Image = imageName;

                admin.Password = Crypto.HashPassword(admin.Password);

                db.Admins.Add(admin);
                db.SaveChanges();
                return(RedirectToAction("Login", "Login"));
            }
            return(View());
        }
Beispiel #22
0
 public ActionResult DeleteConfirmed(int id)
 {
     Models.Admin admin = db.Admins.Find(id);
     db.Admins.Remove(admin);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public ActionResult Create(Models.Admin admin)
        {
            if (ModelState.IsValid)
            {
                Models.Admin Admin = new Models.Admin();

                if (admin.Password != null)
                {
                    Admin.Password = Crypto.HashPassword(admin.Password);
                }

                Admin.Name        = admin.Name;
                Admin.Surname     = admin.Surname;
                Admin.Username    = admin.Username;
                Admin.PhoneNumber = admin.PhoneNumber;
                Admin.Email       = admin.Email;
                Admin.CreatedDate = admin.CreatedDate;

                db.Admins.Add(Admin);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(admin));
        }
Beispiel #24
0
        public async Task <IActionResult> Create([Bind("Name,Email,Password,Designation,Department,Id")] AdminViewModel adminViewModel)
        {
            var md5       = System.Security.Cryptography.MD5.Create();
            var passBytes = Encoding.UTF8.GetBytes(adminViewModel.Password);

            if (ModelState.IsValid)
            {
                adminViewModel.Id       = Guid.NewGuid();
                adminViewModel.Password = Encoding.UTF8.GetString(md5.ComputeHash(passBytes));

                var admin = new Models.Admin
                {
                    Id          = adminViewModel.Id,
                    Name        = adminViewModel.Name,
                    Email       = adminViewModel.Email,
                    Password    = adminViewModel.Password,
                    Designation = adminViewModel.Designation,
                    Department  = adminViewModel.Department,
                    CreatedDate = DateTime.Now
                };

                _context.Add(admin);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(adminViewModel));
        }
Beispiel #25
0
        public ActionResult Login(LoginAdmin login)
        {
            if (ModelState.IsValid)
            {
                Models.Admin admin = db.Admins.FirstOrDefault(a => a.Username == login.Username);

                if (admin != null)
                {
                    if (Crypto.VerifyHashedPassword(admin.Password, login.Password) == true)
                    {
                        Session["Admin"]   = admin;
                        Session["AdminId"] = admin.Id;

                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError("Password", "Wrong password or Username");
                        return(View(login));
                    }
                }
                else
                {
                    ModelState.AddModelError("Username", "Wrong Username");
                    return(View(login));
                }
            }
            return(View(login));
        }
 public SupportRequestAdminViewModel(Models.Admin a)
 {
     Key = a.Key;
     PagerDutyUsername = a.PagerDutyUsername;
     GalleryUsername   = a.GalleryUsername;
     AccessDisabled    = a.AccessDisabled;
 }
        public ActionResult CreateUserAndDraw()
        {
            Models.Admin a_user         = (Models.Admin)Session["admin"];
            Models.Event luckydrawevent = (Models.Event)Session["event"];

            if (a_user == null || luckydrawevent == null)
            {
                return(RedirectToAction("AdminIndex", "Login"));
            }

            var list = new List <SelectListItem>();

            for (var i = 1; i < 41; i++)
            {
                list.Add(new SelectListItem {
                    Text = i.ToString(), Value = i.ToString()
                });
            }

            ViewBag.FloorUnitList = list;
            ViewBag.ProjectList   = GetProjectList(luckydrawevent.EventID);
            ViewBag.SalesLocation = luckydrawevent.EventLocation;
            ViewBag.Name          = a_user.Name;

            DateTime dateTime = DateTime.UtcNow.Date;

            ViewBag.Date = dateTime.ToString("dd | MM | yyyy").ToString();
            ViewBag.Time = DateTime.Now.ToShortTimeString().ToString();

            return(View());
        }
        public ActionResult ExportToExcelWinners()
        {
            Models.Admin a_user         = (Models.Admin)Session["admin"];
            Models.Event luckydrawevent = (Models.Event)Session["event"];

            if (a_user == null || luckydrawevent == null)
            {
                return(RedirectToAction("AdminIndex", "Login"));
            }

            var gv = new GridView();

            gv.DataSource = ToDataTable <User>(GetWinnerList(luckydrawevent.EventID));
            gv.DataBind();

            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=DemoExcel.xls");
            Response.ContentType = "application/ms-excel";

            Response.Charset = "";
            StringWriter   objStringWriter   = new StringWriter();
            HtmlTextWriter objHtmlTextWriter = new HtmlTextWriter(objStringWriter);

            gv.RenderControl(objHtmlTextWriter);

            Response.Output.Write(objStringWriter.ToString());
            Response.Flush();
            Response.End();

            return(View("Index", "Admin"));
        }
        public void DeleteFromDatabase(MainDataContext db, Models.Admin AdminUser)
        {
            foreach (CRM_CalendarVenue venue in this.CRM_CalendarVenues)
            {
                venue.DeleteFromDatabase(db, AdminUser);
            }

            foreach (CRM_CalendarInvite invite in this.CRM_CalendarInvites)
            {
                db.CRM_CalendarInvites.DeleteOnSubmit(invite);
            }

            foreach (CRM_CalendarAdmin admin in this.CRM_CalendarAdmins)
            {
                db.CRM_CalendarAdmins.DeleteOnSubmit(admin);
            }

            foreach (CRM_CalendarAttendance admin in this.CRM_CalendarAttendances)
            {
                db.CRM_CalendarAttendances.DeleteOnSubmit(admin);
            }

            db.CRM_CalendarCPDs.DeleteAllOnSubmit(this.CRM_CalendarCPDs);
            db.CRM_CalendarGroupBookings.DeleteAllOnSubmit(this.CRM_CalendarGroupBookings);
            db.CRM_CalendarOutreaches.DeleteAllOnSubmit(this.CRM_CalendarOutreaches);
            db.CRM_CalendarParties.DeleteAllOnSubmit(this.CRM_CalendarParties);
            db.CRM_CalendarPerHeads.DeleteAllOnSubmit(this.CRM_CalendarPerHeads);
            db.CRM_Tasks.DeleteAllOnSubmit(this.CRM_Tasks);
            db.CRM_CalendarAdmins.DeleteAllOnSubmit(this.CRM_CalendarAdmins);


            History.History.RecordLinqDelete(AdminUser, this);
            db.CRM_Calendars.DeleteOnSubmit(this);
            db.SubmitChanges();
        }
        public ActionResult ModifyUser(int id)
        {
            Models.Admin a_user         = (Models.Admin)Session["admin"];
            Models.Event luckydrawevent = (Models.Event)Session["event"];

            if (a_user == null || luckydrawevent == null)
            {
                return(RedirectToAction("AdminIndex", "Login"));
            }

            Models.User user   = GetUser(id);
            string[]    tokens = user.Unit.Split('-');
            ViewBag.Block = tokens[0];
            ViewBag.Level = tokens[1];
            ViewBag.Unit  = tokens[2];

            var list = new List <SelectListItem>();

            for (var i = 1; i < 41; i++)
            {
                list.Add(new SelectListItem {
                    Text = i.ToString(), Value = i.ToString()
                });
            }

            ViewBag.FloorUnitList = list;
            ViewBag.ProjectList   = GetProjectList(luckydrawevent.EventID);
            ViewBag.SalesLocation = luckydrawevent.EventLocation;
            ViewBag.Name          = a_user.Name;

            return(View(user));
        }
Beispiel #31
0
        public ActionResult Delete(int id, Models.EventView eventView)
        {
            Models.Admin a_user         = (Models.Admin)Session["admin"];
            Models.Event luckydrawevent = (Models.Event)Session["event"];

            if (a_user == null || luckydrawevent == null)
            {
                return(RedirectToAction("AdminIndex", "Login"));
            }

            ViewBag.Name = a_user.Name;

            try
            {
                bool deleted = DeleteExistingEvent(id);

                if (deleted)
                {
                    return(RedirectToAction("Index", "Event"));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Deletion of event failed due to database problem! Ensure all project data and lucky draw data associated with this event is deleted before deleting this event.");
                    return(View());
                }
            }
            catch
            {
                ViewBag.ErrorMessage = "Deletion of event failed.";
                return(View());
            }
        }
Beispiel #32
0
 public ActionResult Login(vAdmin model)
 {
     if (ModelState.IsValid)
     {
         Models.Admin user = new Models.Admin();
         model.Password = Helpers.Encryt.GetMD5(model.Password);
         user = db.Admins.Where(u => u.UserName == model.Username && u.Password == model.Password).SingleOrDefault();
         if (user == null)
         {
             ModelState.AddModelError("", "用户名或密码错误!");
         }
         else
         {
             FormsAuthentication.SetAuthCookie(model.Username, true);
             log.Info(new LogContent(user.UserName + "-管理员登录", Helpers.HttpHelper.GetIPAddress()));
             return RedirectToAction("Index", "Home");
         }
     }
     else
     {
         ModelState.AddModelError("", "登陆信息错误请重新填写!");
     }
     return View(model);
 }
Beispiel #33
0
 public ActionResult ShowAdminPicture(int id)
 {
     Models.Admin admin = new Models.Admin();
     admin = db.Admins.Find(id);
     return File(admin.Picture, "image/jpg");
 }
Beispiel #34
0
 public ActionResult DeleteAdmin(int id)
 {
     Models.Admin admin = new Models.Admin();
     admin = db.Admins.Find(id);
     db.Admins.Remove(admin);
     db.SaveChanges();
     return Content("ok");
 }
Beispiel #35
0
        public ActionResult AdminEditPwd(string Password, int ID)
        {
            Models.Admin admin = new Models.Admin();
            admin = db.Admins.Find(ID);
            if (ModelState.IsValid)
            {
                try
                {
                    admin.Password = Helpers.Encryt.GetMD5(Password);
                    db.SaveChanges();
                    return Redirect("/Admin/System/Manager");
                }
                catch
                {
                    ModelState.AddModelError("", "修改密码失败,请重试!");
                }

            }
            else
            {
                ModelState.AddModelError("", "信息填写不正确!");
            }
            return View(admin);
        }
Beispiel #36
0
 public ActionResult AdminEditPwd(int id)
 {
     Models.Admin admin = new Models.Admin();
     admin = db.Admins.Find(id);
     return View(admin);
 }