Example #1
0
        public BaseViewModel UpdateUser(SaveUserCommand command)
        {
            BaseViewModel vm = new BaseViewModel();

            if (!validator.UserExists(command.User.Username, vm))
            {
                vm.Messages.Add(new Cherries.Models.App.Message
                {
                    LogLevel = Cherries.Models.App.LogLevel.Error,
                    Text     = Messages.UserNotExist
                });
            }
            else
            {
                vm.Messages.Clear();
                repository.ExecuteTransaction(session =>
                {
                    var user       = session.Get <Entities.dbo.Users>(command.User.UserID);
                    user.Name      = command.User.Name;
                    user.CellPhone = command.User.CellPhone;
                    user.Email     = command.User.Email;
                    //user.Currency = AutoMapper.Mapper.Map <Entities.Lookup.SelCurrency>(command.User.Currency);
                    session.Update(user);
                });
            }
            return(vm);
        }
Example #2
0
        public BaseViewModel UpdateUser(SaveUserCommand command)
        {
            BaseViewModel vm = new BaseViewModel();

            vm = userBL.UpdateUser(command);
            return(vm);
        }
Example #3
0
        public async Task <ActionResult> Register([FromBody] RegisterViewModel model)
        {
            var commandResult = new CommandResult();

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    //Id=Guid.NewGuid(),
                    Email       = model.Email,
                    UserName    = model.Email,
                    CreatedDate = new DateTime(),
                    FirstName   = StringHelper.FirstLetterToUpper(model.FirstName),
                    LastName    = StringHelper.FirstLetterToUpper(model.LastName)
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    //  Envoyer un message électronique contenant ce lien
                    await SaveUserCommand.SendConfirmEmailAsync(_emailService, UserManager,
                                                                new SendConfirmEmailModel
                    {
                        Email     = user.Email,
                        FirstName = user.FirstName,
                        LastName  = user.LastName
                    }, user);

                    return(new JsonResult(commandResult));
                }

                // TODO utiliser framework validation
                foreach (var error in result.Errors)
                {
                    commandResult.ValidationResult.AddError("Email", error.Code);
                }
            }
            else
            {
                foreach (var key in ModelState.Keys)
                {
                    var value = ModelState[key];
                    if (value.Errors.Count > 0)
                    {
                        commandResult.ValidationResult.AddError(key, value.Errors[0].ErrorMessage);
                    }
                }
            }

            // If we got this far, something failed, redisplay form
            return(new JsonResult(commandResult));
        }
Example #4
0
        public HttpResponseMessage Create(SaveUserCommand command)
        {
            BaseViewModel vm = new BaseViewModel();

            if (HttpContext.Current.Session["PaymentSum"] == null && command.User.Licence.Licensetype != 3)
            {
                vm.Messages.Add(new Models.App.Message
                {
                    LogLevel = Models.App.LogLevel.Error,
                    Text     = Messages.CalculationMethodNotUsed
                });
            }
            else
            {
                if (command.User.Licence.Licensetype != 3)
                {
                    command.SumInServer = (double)HttpContext.Current.Session["PaymentSum"];
                    command.User.Licence.Transaction.dSum = (double)HttpContext.Current.Session["PaymentSum"];
                }
                else
                {
                    command.SumInServer = 0;
                    command.User.Licence.Transaction.dSum = 0;
                }
                vm = service.CreateUser(command);
                HttpContext.Current.Session["PaymentSum"] = null;
            }

            if (vm.Messages.Count == 0)
            {
                service.SendGreetingsEmail(command.User.Name, command.User.Email);
            }

            return(Request.CreateResponse(HttpStatusCode.OK, vm));
        }
Example #5
0
        public async Task <ActionResult> ResetPassword([FromBody] ResetPasswordModel model)
        {
            var commandResult = new CommandResult();

            if (!ModelState.IsValid)
            {
                foreach (var key in ModelState.Keys)
                {
                    var value = ModelState[key];
                    if (value.Errors.Count > 0)
                    {
                        commandResult.ValidationResult.AddError(key, value.Errors[0].ErrorMessage);
                    }
                }

                return(new JsonResult(commandResult));
            }

            var signedUser = await UserManager.FindByEmailAsync(model.Email);

            var token = await UserManager.GeneratePasswordResetTokenAsync(signedUser);

            await SaveUserCommand.SendResetPasswordEmailAsync(_emailService, signedUser, token);

            return(new JsonResult(commandResult));
        }
Example #6
0
        public Task <CommandResult <User> > Handle(SaveUserCommand request, CancellationToken cancellationToken)
        {
            var response = new CommandResult <User>("Salvo com sucesso", true, null);

            request.Validate();
            if (request.Valid)
            {
                User user = new User(request.Nome, request.Email, request.Senha, request.TipoUsuario);
                if (user.Valid)
                {
                    var result = _userRepository.GetList(x => x.nome == request.Nome && x.email == request.Email);
                    if (result != null && result.Any())
                    {
                        response.Sucesso  = false;
                        response.Mensagem = "Usuário já foi cadastrado com esse nome e email.";
                        return(Task.FromResult(response));
                    }
                    if (_userRepository.Insert(ref user))
                    {
                        response.ObjetoResposta = user;
                        return(Task.FromResult(response));
                    }
                }
                response.Notificacoes.AddRange(user.Notifications.Select(x => x.Message).ToList());
            }
            response.Notificacoes.AddRange(request.Notifications.Select(x => x.Message).ToList());
            response.Sucesso  = false;
            response.Mensagem = "Não foi possível cadastrar o usuário.";
            return(Task.FromResult(response));
        }
Example #7
0
        public IHttpActionResult Create(SaveUserCommand user)
        {
            try
            {
                var returnModel = new BaseReturn();

                if (user == null)
                {
                    return(NotFound());
                }
                else
                {
                    var map = Mapper.Map <SaveUserCommand, User>(user);

                    var valid = serviceUser.Query().Any(x => x.Login == map.Login);

                    if (!valid)
                    {
                        serviceUser.Create(map);

                        return(Ok(returnModel));
                    }

                    return(BadRequest("User already exists."));
                }
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Example #8
0
 private void NotifyAll()
 {
     OnPropertyChanged("SelectedLocationItem");
     OnPropertyChanged("UserProfile");
     OnPropertyChanged("LocationCode");
     OnPropertyChanged("LocationList");
     SaveUserCommand.RaiseCanExecuteChanged();
 }
Example #9
0
 void UserPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     //Komenda SaveUserCommand w metodzie CanExecute sprawdza, czy użytkownik się waliduje.
     //Metoda CanExecute domyślne uruchamiana jest tylko przy tworzeniu bindingu.
     //Dlatego przy właściwości użytkownika musimy za pomocą metody RaiseCanExecuteChanged
     //wymówić jej ponowne wykonanie. Brak tego spowoduje, że interfejs użytkownika nie
     //będzie się aktualizować przy zmiane danych użytkownika.
     SaveUserCommand.RaiseCanExecuteChanged();
 }
        public async Task <ActionResult <CommandResult <User> > > Post([FromBody] SaveUserCommand command)
        {
            var response = await _mediator.Send(command);

            if (response.Sucesso)
            {
                return(Ok(response));
            }
            return(BadRequest(response));
        }
Example #11
0
        public async Task <IActionResult> Save(Guid userId, [FromBody] SaveUserCommand command)
        {
            if (command.Id != userId)
            {
                ModelState.AddModelError(nameof(command.Id), Core.Resources.Validation.RouteParameterMustMatchFormDataParameter);
                return(BadRequest(ModelState));
            }

            return(await _commandSender.ValidateAndSendAsync(command, ModelState));
        }
        public async Task <IActionResult> SaveUser([FromBody] SaveUserCommand command)
        {
            var userDtoResult = await QueryProcessor.GetQueryHandler <SaveUserCommand, UserDto>(command);

            if (userDtoResult.Failure)
            {
                return(BadRequest(userDtoResult.ErrorMessages));
            }

            return(Ok(true));
        }
Example #13
0
        public void Validator(Guid id, bool isActive, Guid systemRoleId, bool isValid)
        {
            var command = new SaveUserCommand()
            {
                Id = id, SystemRoleId = systemRoleId, IsActive = isActive
            };

            var result = _validator.Validate(command);

            result.IsValid.ShouldEqual(isValid);
        }
Example #14
0
        public async Task <IActionResult> AddUser(string name, string password)
        {
            var command = new SaveUserCommand(new User {
                Name = name
            }, password);

            command = await _createUserPipelineBuilder.ProcessAsync(command);

            var cResponse = await _messages.Dispatch(command);

            return(Ok(cResponse));
        }
Example #15
0
        public async Task <CommandResult> SaveUser([FromServices] SaveUserCommand _saveUserCommand, [FromBody] SaveUserInput saveUser)
        {
            var userInput = new UserInput <SaveUserInput>
            {
                Data   = saveUser,
                UserId = User.GetUserId()
            };

            var result = await Business
                         .InvokeAsync <SaveUserCommand, UserInput <SaveUserInput>, CommandResult>(_saveUserCommand, userInput)
                         .ConfigureAwait(false);

            return(result);
        }
Example #16
0
        public AdminWindowViewModel()
        {
            RunList = new ObservableCollection <Run>();

            IsTaskReadOnly   = true;
            IsUserReadOnly   = true;
            IsMarketReadOnly = true;

            SaveTaskCommand   = new SaveTaskCommand(this);
            SaveMarketCommand = new SaveMarketCommand(this);

            ChangeTaskCommand       = new ChangeTaskCommand(this);
            CancelSaveTaskCommand   = new CancelSaveTaskCommand(this);
            ContactDeveloperCommand = new ContactDeveloperCommand(this);
            ResetTaskCommand        = new ResetTaskCommand(this);

            CreateReportCommand = new CreateReportCommand(this);

            CloseCommand    = new CloseWindowCommand();
            MaximizeCommand = new MaximizeWindowCommand();
            MinimizeCommand = new MinimizeWindowCommand();

            CreateUserCommand = new CreateUserCommand(this);
            ChangeUserCommand = new ChangeUserCommand(this);
            SaveUserCommand   = new SaveUserCommand(this);
            CancelUserCommand = new CancelUserCommand(this);
            RemoveUserCommand = new RemoveUserCommand(this);

            TaskIndex   = 0;
            UserIndex   = 0;
            MarketIndex = 0;

            DevList = new List <User>(UserManager.GetUserByGroup(UserGroup.Dev, RunTimeContext.Context.DatabaseContext));

            MarketList = new ObservableCollection <Market>(MarketManager.GetAllMarkets(RunTimeContext.Context.DatabaseContext));
            TaskList   = new ObservableCollection <Task>(TaskManager.GetAllTasks(RunTimeContext.Context.DatabaseContext));
            SetUserList();

            SelectedTask   = TaskList.FirstOrDefault();
            SelectedUser   = UserList.FirstOrDefault();
            SelectedMarket = MarketList.FirstOrDefault();

            StartDate = DateTime.Now.AddMonths(-1);
            EndDate   = DateTime.Now;

            TaskFilter   = TaskList.FirstOrDefault();
            MarketFilter = MarketList.FirstOrDefault();
            DevFilter    = DevList.FirstOrDefault();
        }
Example #17
0
        public void ValidatorValid()
        {
            SetupNewUser();

            SaveUserCommand command;

            using (var db = _dbHelper.GetDbContext())
            {
                command = new SaveUserCommand()
                {
                    Id = db.Users.First().Id, SystemRoleId = db.SystemRoles.First().Id, IsActive = true
                };
            }

            var result = _validator.Validate(command);

            result.IsValid.ShouldBeTrue();
        }
Example #18
0
        public async Task <CommandResponse> Execute(SaveUserCommand command)
        {
            IdentityUser user = new IdentityUser {
                UserName = command.User.Name
            };

            var r = await _userManager.CreateAsync(user, command.Password);

            if (r.Succeeded)
            {
                return(new CommandResponse {
                    ID = user.Id, Success = true
                });
            }
            else
            {
                throw new UserCreateException(string.Format("Code {0} Description {1}", r.Errors.First().Code, r.Errors.First().Description));
            }
        }
Example #19
0
 public IHttpActionResult Update(SaveUserCommand user)
 {
     try
     {
         if (user == null)
         {
             return(NotFound());
         }
         else
         {
             var map = Mapper.Map <SaveUserCommand, User>(user);
             serviceUser.Update(map);
             return(Ok());
         }
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Example #20
0
        public void CreateUserDocument()
        {
            var docUser = new User();

            docUser.Email   = "*****@*****.**";
            docUser.First   = "Nick";
            docUser.Last    = "Shoup";
            docUser.UserKey = docUser.Email;
            docUser.Notes.Add(new Note()
            {
                Description = "Added as a test"
            });
            docUser.Logs.Add(new Log()
            {
                Description = "Added as a test log", Category = "Test Category"
            });
            var quer   = new SaveUserCommand(db);
            var result = quer.Execute(docUser);

            Console.WriteLine($"Added user: {result}");
            Assert.IsTrue(result == 1);
        }
Example #21
0
        public async Task UpdateUser()
        {
            SetupNewUser();

            SaveUserCommand command;

            using (var db = _dbHelper.GetDbContext())
            {
                var dbUser = db.Users.First();
                command = new SaveUserCommand()
                {
                    Id = dbUser.Id, SystemRoleId = dbUser.SystemRoleId, IsActive = !dbUser.IsActive
                };
            }

            await _handler.ExecuteAsync(command);

            using (var db = _dbHelper.GetDbContext())
            {
                db.Users.Single(e => e.Id == command.Id).IsActive.ShouldEqual(command.IsActive);
            }
        }
Example #22
0
        public UserViewModel(UserModel userModel, INavigator navigator)
        {
            _userModel = userModel;
            _userModel.PropertyChanged += (sender, e) => RaisePropertyChanged(e.PropertyName);

            GoBackCommand = new DelegateCommand <object>(parameter =>
            {
                navigator.UpdateCurrentViewModelCommand.Execute(new UpdateCurrentViewModelCommandParameter
                {
                    ViewType  = ViewType.UserList,
                    Parameter = parameter,
                });
            });

            SaveUserCommand = new SaveUserCommand(this, parameter =>
            {
                switch (SaveUserType)
                {
                case SaveUserType.Create:
                    _userModel.CreateUser().ContinueWith(ContinueSavingUser);
                    break;

                case SaveUserType.Update:
                    _userModel.UpdateUser().ContinueWith(ContinueSavingUser);
                    break;
                }
            });

            DeleteUserCommand = new DelegateCommand <object>(parameter =>
            {
                _userModel.DeleteUser().Wait();
                navigator.UpdateCurrentViewModelCommand.Execute(new UpdateCurrentViewModelCommandParameter
                {
                    ViewType  = ViewType.UserList,
                    Parameter = parameter,
                });
            });
        }
Example #23
0
        public async Task <ActionResult> ConfirmEmail(string userId, string code)
        {
            if (userId == null || code == null)
            {
                return(Redirect("/utilisateur/confirmation-email-error?dm=false"));
            }
            IdentityResult result;

            try
            {
                var user = await UserManager.FindByIdAsync(userId);

                result = await UserManager.ConfirmEmailAsync(user, code);
            }
            catch (InvalidOperationException ioe)
            {
                // ConfirmEmailAsync throws when the userId is not found.
                return(Redirect("/utilisateur/confirmation-email-error?dm=false"));
            }

            if (result.Succeeded)
            {
                await SaveUserCommand.AttachRolesAsync(_userService, _siteUserService, userId);

                return(Redirect("/utilisateur/confirmation-email?dm=false"));
            }

            var commandResult = new CommandResult();

            // If we got this far, something failed.
            foreach (var error in result.Errors)
            {
                commandResult.ValidationResult.AddError("Email", error.Code);
            }

            return(Redirect("/utilisateur/confirmation-email-error?dm=false"));
        }
Example #24
0
        private List <Cherries.Models.Lookup.StockMarket> getListOfExchangesByCoupon(List <Cherries.Models.Lookup.StockMarket> colExchanges, SaveUserCommand command)
        {
            List <Cherries.Models.Lookup.StockMarket> colFinalExchanges = new List <Cherries.Models.Lookup.StockMarket>();

            if (command.Cupon == "tak1155449977") // USA
            {
                for (int iRows = 0; iRows < colExchanges.Count; iRows++)
                {
                    if (colExchanges[iRows].id != 1)
                    {
                        colFinalExchanges.Add(colExchanges[iRows]);
                    }
                }
            }

            if (command.Cupon == "tak1187649137") // ISRAEL
            {
                for (int iRows = 0; iRows < colExchanges.Count; iRows++)
                {
                    if (colExchanges[iRows].id == 1)
                    {
                        colFinalExchanges.Add(colExchanges[iRows]);
                    }
                }
            }

            if (colFinalExchanges.Count == 0)
            {
                return(colExchanges);
            }
            return(colFinalExchanges);
        }//getListOfExchangesByCoupon
Example #25
0
 public async Task <IActionResult> PostSaveUser(SaveUserCommand command)
 {
     return(Ok(await _mediator.Send(command)));
 }
Example #26
0
        public HttpResponseMessage Update(SaveUserCommand query)
        {
            var res = service.UpdateUser(query);

            return(Request.CreateResponse(HttpStatusCode.OK, res));
        }
Example #27
0
        //  [ValidateAntiForgeryToken]
        public async Task <IActionResult> ExternalLoginConfirmation([FromBody] ExternalLoginConfirmationViewModel model)
        {
            if (User.Identity.IsAuthenticated)
            {
                throw new Exception("Vous êtes déjà authentifié");
            }
            // Obtenez des informations sur l’utilisateur auprès du fournisseur de connexions externe
            var commandResult = new CommandResult();

            var info = await SignInManager.GetExternalLoginInfoAsync();

            if (ModelState.IsValid)
            {
                if (info == null)
                {
                    commandResult.ValidationResult.AddError("EXTERNAL_PROVIDER",
                                                            "Erreur lors de la récupération des informations du compte externe.");
                    return(new JsonResult(commandResult));
                }

                var user = new ApplicationUser
                {
                    //Id= Guid.NewGuid(),
                    Email       = model.Email,
                    UserName    = model.Email,
                    CreatedDate = new DateTime(),
                    FirstName   = StringHelper.FirstLetterToUpper(model.FirstName),
                    LastName    = StringHelper.FirstLetterToUpper(model.LastName)
                };
                var result = await UserManager.CreateAsync(user);

                if (result.Succeeded)
                {
                    result = await UserManager.AddLoginAsync(user, info);

                    if (result.Succeeded)
                    {
                        await SignInManager.SignInAsync(user, false);

                        // Pour plus d'informations sur l'activation de la confirmation du compte et la réinitialisation du mot de passe, consultez http://go.microsoft.com/fwlink/?LinkID=320771
                        //  Envoyer un message électronique contenant ce lien
                        await SaveUserCommand.SendConfirmEmailAsync(_emailService, UserManager,
                                                                    new SendConfirmEmailModel
                        {
                            Email     = user.Email,
                            FirstName = user.FirstName,
                            LastName  = user.LastName,
                            Provider  = model.Provider
                        }, user);

                        return(new JsonResult(commandResult));
                    }
                }

                // TODO utiliser framework validation
                foreach (var error in result.Errors)
                {
                    commandResult.ValidationResult.AddError("Email", error.Code);
                }
            }
            else
            {
                foreach (var key in ModelState.Keys)
                {
                    var value = ModelState[key];
                    if (value.Errors.Count > 0)
                    {
                        commandResult.ValidationResult.AddError(key, value.Errors[0].ErrorMessage);
                    }
                }
            }

            return(new JsonResult(commandResult));
        }
Example #28
0
        }//getListOfExchangesByCoupon

        public BaseViewModel createNewUser(SaveUserCommand command)
        { // Creates a new user instance and saves to DB (from registration page)
            BaseViewModel vmFinal = new BaseViewModel();

            Entities.dbo.Users           newUser = null;
            Entities.dbo.LicTransactions trans   = null;
            Entities.dbo.Userlicenses    userLic = null;
            if (command.User.Licence.Licensetype == 3)
            {
                if (command.Cupon != _Cupon)
                { // Invalid coupon
                    vmFinal.Messages.Add(new Cherries.Models.App.Message {
                        LogLevel = Cherries.Models.App.LogLevel.Error, Text = "Invalid coupon code"
                    });
                    return(vmFinal);
                }
            }

            // Save user to DB
            if (validator.ValidatePassword(command.Password, vmFinal) && !validator.UserExists(command.User.Username, vmFinal) && validator.ValidatePayment(command.SumInServer, command.User.Licence.Transaction.dSum, vmFinal))
            { // verifies user doesn't already exist + parameters inserted are legal
                repository.ExecuteTransaction(session =>
                {
                    if (command.User.Currency == null)
                    {
                        command.User.Currency = new Cherries.Models.Lookup.Currency {
                            CurrencyId = "9001"
                        }
                    }
                    ;

                    newUser = AutoMapper.Mapper.Map <Entities.dbo.Users>(command.User);
                    userLic = newUser.Userlicenses[0];



                    newUser.Userlicenses = null;
                    SetPassword(newUser, command.Password, false);
                    session.Save(newUser);
                    trans = userLic.Transaction;
                    session.Save(trans);
                    userLic.User         = newUser;
                    userLic.Licensetypes = new Entities.Lookup.Licensetypes {
                        Idlicensetype = command.User.Licence.Licensetype
                    };
                    userLic.Transaction = trans;
                    if (userLic.isTrial)
                    {
                        userLic.dtExpirationDate = DateTime.Today.AddDays(90);
                    }
                    else
                    {
                        userLic.dtExpirationDate = DateTime.Today.AddMonths(userLic.tb_LicServices.Imonths);
                    }
                    userLic.dtActivationDate = DateTime.Today;
                    userLic.dtPurchaseDate   = DateTime.Today;
                    session.SaveOrUpdate(userLic);
                    userLic.Licenseexchanges = new List <Entities.Lookup.Licenseexchanges>();
                    AddExchanges(userLic, command.User.Licence.Stocks.ToList());

                    session.SaveOrUpdate(userLic);
                });
            }
            return(vmFinal);
        }//createNewUser
Example #29
0
        public BaseViewModel CreateUser(SaveUserCommand command)
        {
            BaseViewModel vm = new BaseViewModel();

            Entities.dbo.Users           newUser = null;
            Entities.dbo.LicTransactions trans   = null;
            Entities.dbo.Userlicenses    userLic = null;
            if (command.User.Licence.Licensetype == 3)
            {
                if ((command.Cupon != _Cupon) && (command.Cupon != _CuponIsrael))
                {
                    vm.Messages.Add(new Cherries.Models.App.Message {
                        LogLevel = Cherries.Models.App.LogLevel.Error, Text = "Invalid coupon code"
                    });
                    return(vm);
                }
            }
            if (validator.ValidatePassword(command.Password, vm) && !validator.UserExists(command.User.Username, vm) && validator.ValidatePayment(command.SumInServer, command.User.Licence.Transaction.dSum, vm))
            {
                repository.ExecuteTransaction(session =>
                {
                    var user = session.Query <Entities.dbo.Users>().Where(x => x.Username == command.User.Username).FirstOrDefault();
                    if (command.User.Currency == null)
                    {
                        command.User.Currency = new Cherries.Models.Lookup.Currency {
                            CurrencyId = "9001"
                        }
                    }
                    ;
                    newUser = AutoMapper.Mapper.Map <Entities.dbo.Users>(command.User);
                    userLic = newUser.Userlicenses[0];
                    newUser.Userlicenses = null;
                    SetPassword(newUser, command.Password, false);
                    session.Save(newUser);
                    trans = userLic.Transaction;
                    session.Save(trans);
                    userLic.User         = newUser;
                    userLic.Licensetypes = new Entities.Lookup.Licensetypes {
                        Idlicensetype = command.User.Licence.Licensetype
                    };
                    userLic.Transaction = trans;
                    if (userLic.isTrial)
                    {
                        userLic.dtExpirationDate = DateTime.Today.AddDays(90);
                    }
                    else
                    {
                        userLic.dtExpirationDate = DateTime.Today.AddMonths(userLic.tb_LicServices.Imonths);
                    }
                    userLic.dtActivationDate = DateTime.Today;
                    userLic.dtPurchaseDate   = DateTime.Today;
                    session.SaveOrUpdate(userLic);
                    userLic.Licenseexchanges = new List <Entities.Lookup.Licenseexchanges>();

                    List <Cherries.Models.Lookup.StockMarket> finalExchanges = getListOfExchangesByCoupon(command.User.Licence.Stocks.ToList(), command);
                    AddExchanges(userLic, finalExchanges);
                    //AddExchanges(userLic, command.User.Licence.Stocks.ToList());

                    session.SaveOrUpdate(userLic);
                });
            }
            return(vm);
        }