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;
 }