public ActionResult AddOrDelete(ActionRole model)
        {
            var message = "";

            try
            {
                var ms = dbc.ActionRoles.Single(mr => mr.RoleId == model.RoleId && mr.WebActionId == model.WebActionId);
                dbc.ActionRoles.Remove(ms);
                message = "Xoa Thanh Cong";
            }
            catch
            {
                dbc.ActionRoles.Add(model);
                message = "Them Thanh Cong";
            }

            dbc.SaveChanges();
            return(Content(message));
        }
Example #2
0
 public ActionState(ActionID id, ActionRole owner) : base(id, owner)
 {
 }
Example #3
0
 public void AddActionToRole(ActionRole actionRole)
 {
     _actionRoleRepository.Add(actionRole);
 }
Example #4
0
 public JumpState(ActionRole owner) : base(ActionID.Jump, owner)
 {
 }
Example #5
0
 public IdleState(ActionRole owner) : base(ActionID.Idle, owner)
 {
 }
Example #6
0
 public WalkState(ActionRole owner) : base(ActionID.Walk, owner)
 {
 }
Example #7
0
        public static void Main(string[] args)
        {
            //BuildWebHost(args).Run();

            var host = BuildWebHost(args);

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    var context = services.GetRequiredService <DbServiceContext>();

                    context.Database.EnsureDeleted();
                    if (context.Database.EnsureCreated())
                    {
                        var actions = new Data.Model.Entities.Action[]
                        {
                            new Data.Model.Entities.Action {
                                ActionName = "Register", IdAction = 1
                            },
                            new Data.Model.Entities.Action {
                                ActionName = "Search", IdAction = 2
                            },
                            new Data.Model.Entities.Action {
                                ActionName = "Mark", IdAction = 3
                            }
                        };
                        context.Action.AddRange(actions);
                        context.SaveChanges();

                        var roles = new Role[]
                        {
                            new Role {
                                RoleName = "Assistant", CreationDate = DateTime.Now, CreateBy = "administrador"
                            },
                            new Role {
                                RoleName = "Manager", CreationDate = DateTime.Now, CreateBy = "administrador"
                            },
                            new Role {
                                RoleName = "Administrator", CreationDate = DateTime.Now, CreateBy = "administrador"
                            }
                        };
                        context.Role.AddRange(roles);
                        context.SaveChanges();

                        var actionsRoles = new ActionRole[]
                        {
                            new ActionRole {
                                Role = "Assistant", IdAction = 1, CreationDate = DateTime.Now, CreateBy = "superAdministrador"
                            },
                            new ActionRole {
                                Role = "Assistant", IdAction = 2, CreationDate = DateTime.Now, CreateBy = "superAdministrador"
                            },
                            new ActionRole {
                                Role = "Manager", IdAction = 3, CreationDate = DateTime.Now, CreateBy = "superAdministrador"
                            },
                            new ActionRole {
                                Role = "Administrator", IdAction = 1, CreationDate = DateTime.Now, CreateBy = "superAdministrador"
                            },
                            new ActionRole {
                                Role = "Administrator", IdAction = 2, CreationDate = DateTime.Now, CreateBy = "superAdministrador"
                            },
                            new ActionRole {
                                Role = "Administrator", IdAction = 3, CreationDate = DateTime.Now, CreateBy = "superAdministrador"
                            }
                        };
                        context.ActionRole.AddRange(actionsRoles);
                        context.SaveChanges();
                    }
                    else
                    {
                        context.Database.Migrate();
                    }
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred while seeding the database.");
                }
            }

            host.Run();
        }
Example #8
0
 public RunState(ActionRole owner) : base(ActionID.Run, owner)
 {
 }
 public ActionDescriptionAttribute(ActionRole actionRole, ActionSeverity actionSeverity, string description){
     ActionRole = actionRole;
     ActionSeverity = actionSeverity;
     Description = description;
 }