示例#1
0
        public ActionResult AddOrEditAccount(int id = 0)
        {
            ViewBag.ListChucVu = dbUser.getListQuyen();
            AccountAdminModel accountAdmin = new AccountAdminModel();

            if (id != 0)
            {
                accountAdmin = dbUser.GetAccountById(id);
            }
            return(View(accountAdmin));
        }
示例#2
0
        public bool AddOrEdit(AccountAdminModel accont)
        {
            try
            {
                var XmlImage = new XElement("Image", accont.UserImage);
                if (accont.UserID == 0)
                {
                    ////thêm account
                    UserAdmin userAdmin = new UserAdmin()
                    {
                        UserID         = accont.UserID,
                        UserName       = accont.UserName,
                        UserEmail      = accont.UserEmail,
                        UserDateCreate = accont.UserDateCreate,
                        UserPhone      = accont.UserPhone,
                        UserAddress    = accont.UserAddress,
                        UserLuong      = accont.UserLuong,
                        UserIDQuyen    = accont.IDQuyen,
                        UserImage      = XmlImage.ToString()
                    };
                    data.UserAdmins.Add(userAdmin);
                    data.SaveChanges();
                }
                else
                {
                    ///Sử tai khoản.
                    UserAdmin userAdmin = data.UserAdmins.SingleOrDefault(q => q.UserID == accont.UserID);
                    userAdmin.UserName       = accont.UserName;
                    userAdmin.UserEmail      = accont.UserEmail;
                    userAdmin.UserDateCreate = accont.UserDateCreate;
                    userAdmin.UserPhone      = accont.UserPhone;
                    userAdmin.UserAddress    = accont.UserAddress;
                    userAdmin.UserLuong      = accont.UserLuong;
                    userAdmin.UserIDQuyen    = accont.IDQuyen;
                    userAdmin.UserImage      = XmlImage.ToString();
                    data.SaveChanges();
                }

                return(true);
            }
            catch (Exception) { return(false); }
        }
 public AccountAdminModel Build()
 {
     var model = new AccountAdminModel();
     model.roles = Roles.GetAllRoles().ToList();
     model.users = GetAllUsers();
     if (model.users!=null&&model.users.Any())
     {
        model.users= model.users.Select(
             us =>
                 new UserProfileModel()
                 {
                     UserId = us.UserId,
                     UserName = us.UserName,
                     Discount = (us.Discount != null ? us.Discount : 0),
                     roles = Roles.GetRolesForUser(us.UserName).ToList()
                 }).ToList();
     }
     model.menu = BuildMenu();
     return model;
 }
        public AccountAdminModel Build()
        {
            var model = new AccountAdminModel();

            model.roles = Roles.GetAllRoles().ToList();
            model.users = GetAllUsers();
            if (model.users != null && model.users.Any())
            {
                model.users = model.users.Select(
                    us =>
                    new UserProfileModel()
                {
                    UserId   = us.UserId,
                    UserName = us.UserName,
                    Discount = (us.Discount != null ? us.Discount : 0),
                    roles    = Roles.GetRolesForUser(us.UserName).ToList()
                }).ToList();
            }
            model.menu = BuildMenu();
            return(model);
        }
示例#5
0
        public ActionResult AddOrEditAccount(AccountAdminModel account)
        {
            bool result = dbUser.AddOrEdit(account);

            return(Json(new { Result = result, message = "Lưu Thành Công!" }, JsonRequestBehavior.AllowGet));
        }