Exemplo n.º 1
0
        public UserDbModel Login(UserDbModel dbModel)
        {
            using (DesarrolloDocenteBDEntities db = new DesarrolloDocenteBDEntities())
            {
                var login = (from user in db.SEC_USER
                             where user.EMAIL.ToUpper().Equals(dbModel.Email.ToUpper()) && user.USER_PASSWORD.Equals(dbModel.Password)
                             select user).FirstOrDefault();

                if (login == null)
                {
                    return(null);
                }

                var         date    = dbModel.CurrentDate;
                SEC_SESSION session = new SEC_SESSION()
                {
                    USERID       = login.ID,
                    LOGIN_DATE   = date,
                    TOKEN_STATUS = true,
                    TOKEN        = this.GetToken(String.Concat(login.ID, date)),
                    IP_ADDRESS   = this.GetIpAddress()
                };

                db.SEC_SESSION.Add(session);
                db.SaveChanges();
                UserModelMapper mapper = new UserModelMapper();
                return(mapper.MapperT1T2(login));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public IEnumerable <UserDbModel> RecordList(string filter)
        {
            using (DesarrolloDocenteBDEntities db = new DesarrolloDocenteBDEntities())
            {
                var lista = from role in db.SEC_USER
                            where !role.REMOVED && role.NAME.ToUpper().Contains(filter.ToUpper())
                            select role;

                UserModelMapper mapper     = new UserModelMapper();
                var             listaFinal = mapper.MapperT1T2(lista);

                return(listaFinal);
            }
        }