Пример #1
0
 /// <summary>
 /// Este metodo se encarga de consultar el usuario y validar la cuenta a traves de un servicio externo
 /// </summary>
 /// <param name="AccountDomain">recibe una entidad del tipo accountdomain</param>
 /// <returns>una entidad accountDomainModel</returns>
 public AccountDomainModel ValidarLoginService(AccountDomainModel AccountDomain)
 {/*
   * ServiceClient.wsusuariosSoapClient usuarioClient = new ServiceClient.wsusuariosSoapClient();
   *
   * AccountDomainModel account = new AccountDomainModel();
   #region  Credenciales Externas
   * ServiceClient.Seguridad seguridad = new ServiceClient.Seguridad();
   * seguridad.SegUsuario = Recursos.BaseConfiguration.SegUsuario;
   * seguridad.SegPassword = Recursos.BaseConfiguration.SegPassword;
   #endregion
   *
   #region Validacion del usuario Interno
   * ServiceClient.Usuario usuario = new ServiceClient.Usuario();
   * usuario.NomUsuario = AccountDomain.Nombre;
   * usuario.Password = AccountDomain.Password;
   #endregion
   *
   #region Consumo de Servicio
   * var user= usuarioClient.ConsultaUsuarios(seguridad, usuario);
   * if (user != null)
   * {
   *     account.IdUsuario = int.Parse(user.IdUsuario);
   *     account.Nombre = user.Nombre;
   *     account.NombreCompleto = user.Nombre + " " + user.ApellidoPaterno + " " + user.ApellidoMaterno;
   *     account.Password = user.Clave;
   *     account.Email = user.Correo_Electronico;
   * }
   * return account;
   #endregion
   */
     return(null);
 }
        public async Task <string> AddUpdateUser(AccountVM accountVM)
        {
            AccountDomainModel accountDM = new AccountDomainModel();

            AutoMapper.Mapper.Map(accountVM, accountDM);
            return(await accountBusiness.AddUpdateAccount(accountDM));
        }
        public async Task <string> AddUpdateAccount(AccountDomainModel account)
        {
            string status = "";

            if (account.acc_id > 0)
            {
                tblAccount accountToUpdate = await accountRepository.SingleOrDefault(c => c.acc_id == account.acc_id);

                if (accountToUpdate != null)
                {
                    accountToUpdate.name       = account.name;
                    accountToUpdate.AccType_id = account.AccType_id;
                    accountToUpdate.balance    = account.balance;
                    await accountRepository.Update(accountToUpdate);

                    status = "updated";
                }
            }
            else
            {
                tblAccount accountToAdd = new tblAccount();
                accountToAdd.name       = account.name;
                accountToAdd.AccType_id = account.AccType_id;
                accountToAdd.balance    = account.balance;
                await accountRepository.Insert(accountToAdd);

                status = "added";
            }
            return(status);
        }
Пример #4
0
 public override void OnAuthorization(AuthorizationContext filterContext)
 {
     if (SessionPersister.AccountSession == null)
     {
         //si no viene vacio el objeto entramos sin problema
         filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { controller = "Seguridad", action = "Login" }));
     }
     else
     {
         AccountDomainModel accountModel = new AccountDomainModel();
         AccountViewModel   viewAccount  = SessionPersister.AccountSession;
         AutoMapper.Mapper.Map(viewAccount, accountModel);
         accountModel = IaccountBusiness.ValidarLogin(accountModel);
         AutoMapper.Mapper.Map(accountModel, viewAccount);
         CustomPrincipal customPrincipal = new CustomPrincipal(viewAccount);
         filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { controller = "Seguridad", action = "Login" }));
     }
     //if (string.IsNullOrEmpty(SessionPersister.Username))
     //    filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { controller = "Seguridad", action = "Login" }));
     //else
     //{
     //    AccountViewModel am = new AccountViewModel();
     //    CustomPrincipal customPrincipal = new CustomPrincipal(am.Find(SessionPersister.Username));
     //    if (!customPrincipal.IsInRole(Roles))
     //        filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { controller = "Seguridad", action = "Login" }));
     //}
 }
Пример #5
0
        private void UpdateAccount(AccountDomainModel item)
        {
            using (var ctx = new BankAccountDbContext())
            {
                var entity = ctx.AccountSet.SingleOrDefault(b => b.AggregateId == item.Id);
                if (entity == null)
                {
                    throw new AggregateNotFoundException("account");
                }

                var customerEntityId =
                    ctx.CustomerSet.SingleOrDefault(c => c.AggregateId == item.CustomerId);
                if (customerEntityId == null)
                {
                    throw new AggregateNotFoundException("Bank account");
                }

                entity.Version             = item.Version;
                entity.Currency            = item.Currency;
                entity.CustomerAggregateId = item.CustomerId;
                entity.AccountState        = item.State;

                ctx.Entry(entity).State = EntityState.Modified;
                ctx.SaveChanges();
            }
        }
        public async Task <AccountToReturnVM> GetAccountById(int id)
        {
            AccountToReturnVM  accountToReturnVM  = new AccountToReturnVM();
            AccountDomainModel accountDomainModel = await accountBusiness.GetAccountById(id);

            AutoMapper.Mapper.Map(accountDomainModel, accountToReturnVM);
            return(accountToReturnVM);
        }
Пример #7
0
        public string ConfirmAddAccount(AccountViewModel vm)
        {
            AccountDomainModel acc_dm = new AccountDomainModel();
            var    mapper_accs        = new MapperConfiguration(cfg => cfg.CreateMap <AccountViewModel, AccountDomainModel>()).CreateMapper();
            var    account            = mapper_accs.Map <AccountViewModel, AccountDomainModel>(vm);
            string response           = accs.Add(account);

            return(response);
        }
Пример #8
0
        public bool ExistUsuario(AccountDomainModel _accountDomainModel)
        {
            bool        respuesta   = false;
            catUsuarios catUsuarios = new catUsuarios();

            catUsuarios = accountRepository.GetAll().FirstOrDefault(p => p.strNombrUsuario == _accountDomainModel.Email);

            if (catUsuarios != null)
            {
                respuesta = true;
            }

            return(respuesta);
        }
        public async Task <AccountDomainModel> GetAccountById(int id)
        {
            AccountDomainModel account = new AccountDomainModel();
            var model = await accountRepository.SingleOrDefault(a => a.acc_id == id);

            if (model != null)
            {
                account.acc_id     = model.acc_id;
                account.name       = model.name;
                account.AccType_id = model.AccType_id;
                account.balance    = model.balance;
            }
            return(account);
        }
Пример #10
0
 public string Add(AccountDomainModel DM)
 {
     if ((DM.Name == null) || (Convert.ToDouble(DM.Amount) < 0))
     {
         return("One or more fields are empty");
     }
     else
     {
         account acc = new account();
         acc.Name   = DM.Name;
         acc.Amount = Convert.ToDouble(DM.Amount);
         accRep.Insert(acc);
         return("");
     }
 }
Пример #11
0
 public string Edit(AccountDomainModel DM)
 {
     if ((DM.Name == null) || (Convert.ToDouble(DM.Amount) < 0))
     {
         return("One or more fields are empty");
     }
     else
     {
         account acc = accRep.SingleOrDefault(x => x.ID == DM.ID);
         acc.Name   = DM.Name;
         acc.Amount = Convert.ToDouble(DM.Amount);
         accRep.Update(acc);
         return("");
     }
 }
Пример #12
0
        public ActionResult Login(AccountViewModel accountViewModel)
        {
            usuario.NomUsuario = accountViewModel.Email;
            usuario.Password   = accountViewModel.Password;

            AccountDomainModel accountDomainModel = new AccountDomainModel();

            AutoMapper.Mapper.Map(accountViewModel, accountDomainModel);

            if (IAccountBusiness.ExistUsuario(accountDomainModel))
            {
                accountDomainModel = IAccountBusiness.ValidarLogin(accountDomainModel);


                if (accountDomainModel != null)
                {
                    AccountViewModel viewAccount = new AccountViewModel();
                    AutoMapper.Mapper.Map(accountDomainModel, viewAccount);
                    SessionPersister.AccountSession = viewAccount;
                }
            }
            else
            {
                var res = wsusuariosSoapClient.ConsultaUsuarios(seguridad, usuario);
                //var sigeAlumnp = wsusuariosSoapClient.ConsultaUsuariosAlumno(seguridad, usuario);

                PersonalDomainModel personalDomainModel = new PersonalDomainModel();
                if (res.Nombre_usuario != null && res.Clave != null)
                {
                    _ = res.Nombre == null ? res.Nombre = "..." : res.Nombre = res.Nombre;
                    personalDomainModel.Nombre             = res.Nombre;
                    personalDomainModel.ApellidoPaterno    = res.ApellidoPaterno;
                    personalDomainModel.ApellidoMaterno    = res.ApellidoMaterno;
                    personalDomainModel.AccountDomainModel = new AccountDomainModel {
                        Email = res.Correo_Electronico, Password = usuario.Password, Nombre = usuario.NomUsuario, TipoUsuario = res.TipoUsuario.ToString()
                    };
                    personalDomainModel.strTipoPersonal = res.TipoPersonal.ToString();
                    personalDomainModel.strUniversidad  = res.Universidad;

                    if (IAccountBusiness.AddUsuario(personalDomainModel))
                    {
                        Login(accountViewModel);
                    }
                }
            }
            return(RedirectToAction("Create", "Personal"));
        }
        public void Execute(AddAccountCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            var aggregate = new AccountDomainModel();

            aggregate.CreateNewAccount(
                command.Id,
                command.CustomerId,
                command.Version,
                command.Currency);

            this.Repository.Save(aggregate, aggregate.Version);
        }
Пример #14
0
        public void Save(AccountDomainModel item)
        {
            AccountEntity entity;

            using (var ctx = new BankAccountDbContext())
            {
                entity = ctx.AccountSet.SingleOrDefault(a => a.AggregateId == item.Id);
            }

            if (entity == null)
            {
                this.AddAccount(item);
            }
            else
            {
                this.UpdateAccount(item);
            }
        }
Пример #15
0
        private void AddAccount(AccountDomainModel item)
        {
            using (var ctx = new BankAccountDbContext())
            {
                var customerEntityId =
                    ctx.CustomerSet.SingleOrDefault(c => c.AggregateId == item.CustomerId);
                if (customerEntityId == null)
                {
                    throw new AggregateNotFoundException("Bank account");
                }

                ctx.AccountSet.Add(new AccountEntity
                {
                    AggregateId         = item.Id,
                    Version             = item.Version,
                    CustomerAggregateId = item.CustomerId,
                    Currency            = item.Currency,
                    AccountState        = State.Open
                });
                ctx.SaveChanges();
            }
        }
Пример #16
0
        public ActionResult Login(AccountViewModel accountViewModel)
        {
            AccountDomainModel accountDomainModel = new AccountDomainModel();

            AutoMapper.Mapper.Map(accountViewModel, accountDomainModel);

            if (!string.IsNullOrEmpty(accountViewModel.Email) && !string.IsNullOrEmpty(accountViewModel.Password))
            {
                accountDomainModel = IAccountBusiness.ValidarLogin(accountDomainModel);
                if (accountDomainModel != null)
                {
                    AccountViewModel viewAccount = new AccountViewModel();
                    AutoMapper.Mapper.Map(accountDomainModel, viewAccount);
                    SessionPersister.AccountSession = viewAccount;
                    return(RedirectToAction("Create", "Personal"));
                }
                else
                {
                    ViewBag.Validar = Recursos.RecursosSistema.USUARIO_INEXISTENTE;
                }
            }
            return(View());
        }
Пример #17
0
        /// <summary>
        /// Este metodo se encarga de validar el login de un usuario
        /// </summary>
        /// <param name="AccountDomain">recibe un accountDomain como objeto pasado por parametro</param>
        /// <returns>un valor booleano</returns>
        public bool Login(AccountDomainModel AccountDomain)
        {
            Expression <Func <catUsuarios, bool> > predicado = p => p.strEmailInstitucional == AccountDomain.Email && p.strPassword == AccountDomain.Password;

            return(accountRepository.Exists(predicado));
        }