コード例 #1
0
ファイル: UserController.cs プロジェクト: samuraitruong/gmr
        public ActionResult Create(UserCreateModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    User i = new User()
                    {
                        UserName = model.Username,
                        Password = model.Password,
                        Email = model.Email,
                        Description = model.Description,
                        FullName = model.Fullname,
                        Occupation = model.Occupation,
                        Address = model.Address,
                        Industry = model.Industry,
                        AnualIcome = model.AnualIncome,
                        BirthYear = model.BirthYear,
                        UserTypeID = model.UserTypeId,
                        PhoneNumber1 = model.Phone1,
                        PhoneNumber2 = model.Phone2,
                        PhoneNumber3 = model.Phone3,
                        CreatedUserID = SessionManager.UserInfo.UserID,
                        UpdatedUserID = SessionManager.UserInfo.UserID,
                        GroupID = model.GroupID,
                    };
                    if (model.PartnerId > .0)
                    {
                        i.PartnerId = model.PartnerId;
                    }
                    UserService.AddUser(i);
                    return RedirectToAction("Index");
                }

            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error_500","Đã có lỗi hệ thống xãy ra, không thể cập nhật được dữ liệu");
                Logger.Log(ex);

            }
            return View(model);
        }
コード例 #2
0
ファイル: UIHelper.cs プロジェクト: samuraitruong/gmr
        public static UserInfo BuildUserInfo(User u)
        {
            var info = new UserInfo()
            {
                PartnerId = u.PartnerId.HasValue ? u.PartnerId.Value : -1,
                UserID = u.UserID,
                FullName = u.FullName,
                Roles = u.UserType.UserTypeName,
                Permissions = new List<PermissionInfo>(),
                IsSystemAdministrator = u.IsSA(),
            };

            List<Permission> permissions = new List<Permission>();
            permissions.AddRange(u.Permissions.ToList());
            if(u.Group!= null) permissions.AddRange(u.Group.Permissions);

            var grouped = permissions.GroupBy(p => p.Module);
            var distinctPermissions = new List<PermissionInfo>();
            foreach (var items in grouped)
            {

                PermissionInfo pi = new PermissionInfo()
                {
                    Module = items.Key.Name,
                    Actions = items.Key.Keys.Split(";".ToCharArray()),
                    Permissions = new  List<Permissions>()
                };
                foreach (var item in items)
                {
                    EnsurePermission(pi.Permissions, Permissions.Full, item.Full);
                    EnsurePermission(pi.Permissions, Permissions.Create, item.Create);
                    EnsurePermission(pi.Permissions, Permissions.Edit, item.Edit);
                    EnsurePermission(pi.Permissions, Permissions.Read, item.Read);
                }
                info.Permissions.Add(pi);
            }

            return info;
        }
コード例 #3
0
ファイル: GMR.Designer.cs プロジェクト: samuraitruong/gmr
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="userID">Initial value of the UserID property.</param>
 /// <param name="userName">Initial value of the UserName property.</param>
 /// <param name="fullName">Initial value of the FullName property.</param>
 /// <param name="phoneNumber1">Initial value of the PhoneNumber1 property.</param>
 /// <param name="userTypeID">Initial value of the UserTypeID property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="createdDate">Initial value of the CreatedDate property.</param>
 public static User CreateUser(global::System.Int32 userID, global::System.String userName, global::System.String fullName, global::System.String phoneNumber1, global::System.Int32 userTypeID, global::System.String email, global::System.DateTime createdDate)
 {
     User user = new User();
     user.UserID = userID;
     user.UserName = userName;
     user.FullName = fullName;
     user.PhoneNumber1 = phoneNumber1;
     user.UserTypeID = userTypeID;
     user.Email = email;
     user.CreatedDate = createdDate;
     return user;
 }
コード例 #4
0
ファイル: UserController.cs プロジェクト: samuraitruong/gmr
        public ActionResult Edit(int id, EditUserModel model)
        {
            try
            {

                if (ModelState.IsValid)
                {
                    User user = new User()
                    {
                        UserID = model.UserID,
                        UserName = model.Username,
                        Password = model.Password,
                        Email = model.Email,
                        Description = model.Description,
                        FullName = model.Fullname,
                        Occupation = model.Occupation,
                        Address = model.Address,
                        Industry = model.Industry,
                        AnualIcome = model.AnualIncome,
                        BirthYear = model.BirthYear,
                        UserTypeID = model.UserTypeId,
                        PhoneNumber1 = model.Phone1,
                        PhoneNumber2 = model.Phone2,
                        PhoneNumber3 = model.Phone3,
                        //CreatedUserID = SessionManager.UserInfo.UserID,
                        UpdatedUserID = SessionManager.UserInfo.UserID,
                        GroupID = model.GroupID,
                    };
                    if (model.PartnerId > .0)
                    {
                        user.PartnerId = model.PartnerId;
                    }
                    UserService service = new UserService();
                    service.Update(user);
                    return RedirectToAction("Index");
                }
                // TODO: Add update logic here

            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                ModelState.AddModelError("Error500", ex.Message);
            }
            return View(model);
        }
コード例 #5
0
ファイル: GMR.Designer.cs プロジェクト: samuraitruong/gmr
 /// <summary>
 /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsers(User user)
 {
     base.AddObject("Users", user);
 }