Ejemplo n.º 1
0
        public override void Execute()
        {
            if (Repository.Query(whereSpecification: new UserByLoginWhereSpec(Login))
                .Any())
            {
                throw IncWebException.For <AddUserCommand>(r => r.Login, "Login not unique");
            }

            var user = new User
            {
                Login     = Login,
                Password  = Password,
                Activated = false
            };

            Repository.Save(user);

            string urlConfirm = PathResult + "?UserId={0}".F(user.Id.ReturnOrDefault(r => r, "Debug"));

            EventBroker.Publish(new OnSendEmailEvent
            {
                To      = Login,
                Subject = "Confirm registration",
                Body    = "Please confirm email {0}".F(urlConfirm)
            });

            EventBroker.Publish(new OnChangeSearchItemEvent(user));
        }
Ejemplo n.º 2
0
        public override void Execute()
        {
            var user = Repository
                       .Query(whereSpecification: new UserByCredentialWhereSpec(Email, Password))
                       .FirstOrDefault();

            if (user == null)
            {
                throw IncWebException.ForServer("Please use correct email and password");
            }

            EventBroker.Publish(new SingInUserEvent(user, RememberMe));
        }
        protected override void Execute()
        {
            var product = new Product()
            {
                Name = "Will be save alone"
            };

            Repository.Save(product);
            if (IsThrow)
            {
                throw IncWebException.ForServer("Test");
            }
        }
        protected async Task <ActionResult> TryPushAsync(Func <CommandComposite, Task> push, CommandComposite composite, Action <IncTryPushSetting> action = null, bool?isAjax = null)
        {
            var setting = new IncTryPushSetting();

            action.Do(r => r(setting));

            Func <ActionResult> defaultSuccess = () => View(composite.Parts[0]);
            var isActualAjax = isAjax.GetValueOrDefault(HttpContext.Request.IsAjaxRequest());

            if (isActualAjax)
            {
                defaultSuccess = () => IncodingResult.Success();
            }
            var success = setting.SuccessResult ?? defaultSuccess;

            Func <IncWebException, ActionResult> defaultError = (ex) => View(composite.Parts[0]);

            if (isActualAjax)
            {
                defaultError = (ex) => IncodingResult.Error((ModelStateDictionary)ModelState);
            }
            var error = setting.ErrorResult ?? defaultError;

            if (!ModelState.IsValid)
            {
                return(error(IncWebException.For(string.Empty, string.Empty)));
            }

            try
            {
                await push(composite);

                return(success());
            }
            catch (IncWebException exception)
            {
                foreach (var pairError in exception.Errors)
                {
                    foreach (var errorMessage in pairError.Value)
                    {
                        ModelState.AddModelError(pairError.Key, errorMessage);
                    }
                }

                return(error(exception));
            }
        }
Ejemplo n.º 5
0
        public override void Execute()
        {
            var user = Repository.Query(whereSpecification: new UserByLoginWhereSpec(Email)).SingleOrDefault();

            if (user == null)
            {
                throw IncWebException.For <ForgotUserPasswordCommand>(r => r.Email, "User not exists");
            }

            user.ResetToken = Token;
            EventBroker.Publish(new OnSendEmailEvent
            {
                To      = Email,
                Subject = "Your new random password from Browsio",
                Body    = "Please follow the link to change password : <a=href\"{0}\"".F(ChangePasswordUrl)
            });
        }
Ejemplo n.º 6
0
        protected ActionResult TryPush(CommandComposite composite, Action <IncTryPushSetting> action = null)
        {
            var setting = new IncTryPushSetting();

            action.Do(r => r(setting));

            Func <ActionResult> defaultSuccess = () => View(composite.Parts[0]);

            if (HttpContext.Request.IsAjaxRequest())
            {
                defaultSuccess = () => IncodingResult.Success();
            }
            var success = setting.SuccessResult ?? defaultSuccess;

            Func <IncWebException, ActionResult> defaultError = (ex) => View(composite.Parts[0]);

            if (HttpContext.Request.IsAjaxRequest())
            {
                defaultError = (ex) => IncodingResult.Error(ModelState);
            }
            var error = setting.ErrorResult ?? defaultError;

            if (!ModelState.IsValid)
            {
                return(error(IncWebException.For(string.Empty, string.Empty)));
            }

            try
            {
                dispatcher.Push(composite);
                return(success());
            }
            catch (IncWebException exception)
            {
                foreach (var pairError in exception.Errors)
                {
                    foreach (var errorMessage in pairError.Value)
                    {
                        ModelState.AddModelError(pairError.Key, errorMessage);
                    }
                }

                return(error(exception));
            }
        }
        public override void Execute()
        {
            var user = Repository
                       .Query(whereSpecification: new UserByCredentialWhereSpec(Email, Password))
                       .FirstOrDefault();

            if (user == null)
            {
                throw IncWebException.ForServer("Please use correct email and password");
            }

            Dispatcher.Push(new SignInFormCommand()
            {
                Login       = user.Email,
                Id          = user.Id,
                Persistence = RememberMe
            });
        }
        protected override void Execute()
        {
            var product = new Product()
            {
                Name = "Will be save edition 0"
            };

            Repository.Save(product);
            for (int i = 1; i < 10; i++)
            {
                Dispatcher.Push(new InnerCommand()
                {
                    Index = i
                });
            }
            if (IsThrow)
            {
                throw IncWebException.ForServer("Test");
            }
        }
        protected override void Execute()
        {
            var product = new Product()
            {
                Name = "Will be save TEST2 edition 0"
            };

            Repository.Save(product);
            for (int i = 1; i < 10; i++)
            {
                Dispatcher.Push(new InnerCommand()
                {
                    Index = i
                }, setting => { setting.Connection = ConfigurationManager.ConnectionStrings["Main2"].ConnectionString; });
            }

            if (IsThrow)
            {
                throw IncWebException.ForServer("Test");
            }
        }
Ejemplo n.º 10
0
        public override void Execute()
        {
            var categoryOfType = (CategoryOfType)Category;

            var store = Repository.GetById <Store>(Id);

            if (store.Category != categoryOfType && Repository.Query(whereSpecification: new StoreByCategoryOptWhereSpec(categoryOfType).And(new StoreByUserWhereSpec(BrowsioApp.UserId)))
                .Any())
            {
                throw IncWebException.For <AddStoreCommand>(r => r.Category, "Store with {0} category exist".F(categoryOfType.ToLocalization()));
            }

            store.Category    = categoryOfType;
            store.Name        = Name;
            store.Description = Description;
            store.Genre       = Repository.GetById <Genre>(GenreId);
            if (Image != null)
            {
                store.Image = new HttpMemoryPostedFile(Image).ContentAsBytes;
            }

            EventBroker.Publish(new OnChangeSearchItemEvent(store));
        }
Ejemplo n.º 11
0
        public override void Execute()
        {
            var categoryOfType = (CategoryOfType)Category;

            if (Repository.Query(whereSpecification: new StoreByCategoryOptWhereSpec(categoryOfType).And(new StoreByUserWhereSpec(BrowsioApp.UserId)))
                .Any())
            {
                throw IncWebException.For <AddStoreCommand>(r => r.Category, "Store with {0} category exist".F(categoryOfType.ToLocalization()));
            }

            var user  = Repository.GetById <User>(BrowsioApp.UserId);
            var store = new Store
            {
                Category    = categoryOfType,
                Description = Description,
                Image       = Image.ReturnOrDefault(@base => new HttpMemoryPostedFile(@base).ContentAsBytes, new byte[0]),
                Genre       = Repository.GetById <Genre>(GenreId),
                Name        = Name
            };

            user.AddStore(store);

            EventBroker.Publish(new OnChangeSearchItemEvent(store));
        }
 protected override string ExecuteResult()
 {
     throw IncWebException.ForServer("Test");
 }