public CommandResponse Execute()
        {
            var db = new TheatreUZContext();

            var response = new CommandResponse()
            {
                Success = false
            };

            try
            {
                var item = db.Notifications.FirstOrDefault(w => w.ID == command.NotificationID);

                db.Entry(item);
                item.StateID = db.States.Where(s => s.Name == "Deleted").FirstOrDefault().ID;
                db.SaveChanges();

                response.ID      = item.ID;
                response.Success = true;
                response.Message = "Deleted state.";
            }
            catch
            {
            }

            return(response);
        }
        public CommandResponse Execute()
        {
            var db = new TheatreUZContext();

            var response = new CommandResponse()
            {
                Success = false
            };

            try
            {
                var item = db.Notifications.FirstOrDefault(w => w.ID == command.Notification.ID);

                if (item == null)
                {
                    command.Notification.ID = Guid.NewGuid();
                    db.Notifications.Add(command.Notification);
                }
                else
                {
                    db.Entry(item);
                    item.Message = command.Notification.Message;
                    item.UserID  = command.Notification.UserID;
                    item.StateID = command.Notification.StateID;
                    item.RegDate = command.Notification.RegDate;
                }

                db.SaveChanges();

                response.ID      = item.ID;
                response.Success = true;
                response.Message = "Saved state.";
            }
            catch
            {
            }

            return(response);
        }
예제 #3
0
 public AllSalesQueryHandler(TheatreUZContext dbContext)
 {
     db = dbContext;
 }
예제 #4
0
 public static IQueryHandler <OneSaleQuery, Sale> Build(OneSaleQuery query, TheatreUZContext dbContext)
 {
     return(new OneSaleQueryHandler(query, dbContext));
 }
예제 #5
0
 public static IQueryHandler<OneRoleQuery, Role> Build(OneRoleQuery query, TheatreUZContext dbContext)
 {
     return new OneRoleQueryHandler(query, dbContext);
 }
 public static ICommandHandler <NotificationSaveCommand, CommandResponse> Build(NotificationSaveCommand command, TheatreUZContext dbContext)
 {
     return(new NotificationSaveCommandHandler(command, dbContext));
 }
예제 #7
0
 public static ICommandHandler <SaleSaveCommand, CommandResponse> Build(SaleSaveCommand command, TheatreUZContext dbContext)
 {
     return(new SaleSaveCommandHandler(command, dbContext));
 }
예제 #8
0
 public static ICommandHandler <SpectacleDeleteCommand, CommandResponse> Build(SpectacleDeleteCommand command, TheatreUZContext dbContext)
 {
     return(new SpectacleDeleteCommandHandler(command, dbContext));
 }
예제 #9
0
 public static ICommandHandler <GenreDeleteCommand, CommandResponse> Build(GenreDeleteCommand command, TheatreUZContext dbContext)
 {
     return(new GenreDeleteCommandHandler(command, dbContext));
 }
예제 #10
0
 public OneNotificationQueryHandler(OneNotificationQuery query, TheatreUZContext dbContext)
 {
     this.query = query;
     db         = dbContext;
 }
예제 #11
0
 public AllNotificationsQueryHandler(TheatreUZContext dbContext)
 {
     db = dbContext;
 }
예제 #12
0
 public static IQueryHandler <OneNotificationQuery, Notification> Build(OneNotificationQuery query, TheatreUZContext dbContext)
 {
     return(new OneNotificationQueryHandler(query, dbContext));
 }
예제 #13
0
 public UserSaveCommandHandler(UserSaveCommand command, TheatreUZContext dbContext)
 {
     this.command = command;
     db           = dbContext;
 }
 public NotificationDeleteCommandHandler(NotificationDeleteCommand command, TheatreUZContext dbContext)
 {
     this.command = command;
     db           = dbContext;
 }
예제 #15
0
 public OneSaleQueryHandler(OneSaleQuery query, TheatreUZContext dbContext)
 {
     this.query = query;
     db         = dbContext;
 }
예제 #16
0
 public static IQueryHandler <AllSalesQuery, IEnumerable <Sale> > Build(AllSalesQuery query, TheatreUZContext dbContext)
 {
     return(new AllSalesQueryHandler(dbContext));
 }
예제 #17
0
 public static IQueryHandler <AllNotificationsQuery, IEnumerable <Notification> > Build(AllNotificationsQuery query, TheatreUZContext dbContext)
 {
     return(new AllNotificationsQueryHandler(dbContext));
 }
예제 #18
0
 public GenreDeleteCommandHandler(GenreDeleteCommand cmd, TheatreUZContext dbContext)
 {
     command = cmd;
     db      = dbContext;
 }
예제 #19
0
 public static ICommandHandler<StateDeleteCommand, CommandResponse> Build(StateDeleteCommand command, TheatreUZContext dbContext)
 {
     return new StateDeleteCommandHandler(command, dbContext);
 }
예제 #20
0
 public SpectacleSaveCommandHandler(SpectacleSaveCommand command, TheatreUZContext dbContext)
 {
     this.command = command;
     db           = dbContext;
 }
예제 #21
0
 public static IQueryHandler <OneUserByEmailQuery, User> Build(OneUserByEmailQuery query, TheatreUZContext dbContext)
 {
     return(new OneUserByEmailQueryHandler(query, dbContext));
 }
예제 #22
0
 public SaleDeleteCommandHandler(SaleDeleteCommand command, TheatreUZContext dbContext)
 {
     this.command = command;
     db           = dbContext;
 }
예제 #23
0
 public OneUserByEmailQueryHandler(OneUserByEmailQuery query, TheatreUZContext dbContext)
 {
     this.query = query;
     db         = dbContext;
 }