Beispiel #1
0
        public override List <cstRoleTbl> Execute()
        {
            List <cstRoleTbl> roleList = new List <cstRoleTbl>();

            local_x3v6Entities context = new local_x3v6Entities();

            switch (_action)
            {
            case csteActionenum.New:
                Role role = new Role();
                role.RoleId          = Guid.NewGuid();
                role.Name            = _role.Name;
                role.Action          = _role.Action;
                role.CreatedBy       = GlobalClasses.ClGlobal.UserID;
                role.CreatedDateTime = DateTime.UtcNow;
                context.AddToRoles(role);
                context.SaveChanges();
                break;

            case csteActionenum.Update:
                Role roleTypeUpdate = context.Roles.First(i => i.RoleId == _role.RoleId);
                roleTypeUpdate.Name            = _role.Name;
                roleTypeUpdate.Action          = _role.Action;
                roleTypeUpdate.Updatedby       = GlobalClasses.ClGlobal.UserID;
                roleTypeUpdate.UpdatedDateTime = DateTime.UtcNow;
                context.SaveChanges();
                break;

            case csteActionenum.Delete:
                break;

            case csteActionenum.Get:
                var result = from r in context.Roles
                             where r.RoleId == _id
                             select r;
                foreach (var varRole in result)
                {
                    cstRoleTbl objRole = new cstRoleTbl();
                    objRole.RoleId = varRole.RoleId;
                    objRole.Name   = varRole.Name;
                    objRole.Action = varRole.Action;
                    roleList.Add(objRole);
                }
                break;
            }

            return(roleList);
        }