예제 #1
0
        public BusinessResult CreateUser(BOUser objUser)
        {
            BusinessResult result = new BusinessResult();

            if (!_userService.IsValid(objUser))
            {
                result.Success    = false;
                result.ErrorsList = _userService.Errors;
                return(result);
            }

            using (var conexion = Util.GetConnection())
            {
                conexion.Open();
                using (var objPE = new UserPE())
                {
                    try
                    {
                        objUser.Id = objPE.CreateUser(conexion, objUser);

                        result.Success = true;
                        result.Other   = objUser;
                    }
                    catch (Exception error)
                    {
                        result.ErrorsList.Add(error.Message);
                    }
                }
            }

            return(result);
        }
예제 #2
0
        public BusinessResult UpdateUser(BOUser objUser)
        {
            BusinessResult result = new BusinessResult();

            using (var conexion = Util.GetConnection())
            {
                conexion.Open();
                using (var objPE = new UserPE())
                {
                    try
                    {
                        objPE.UpdateUser(conexion, objUser);

                        result.Success = true;
                        result.Other   = objUser;
                    }
                    catch (Exception error)
                    {
                        result.ErrorsList.Add(error.Message);
                    }
                }
            }

            return(result);
        }
예제 #3
0
        public BusinessResult GetUserById(int id)
        {
            BusinessResult result = new BusinessResult();

            using (var conexion = Util.GetConnection())
            {
                conexion.Open();
                using (var objPE = new UserPE())
                {
                    try
                    {
                        BOUser objUser = objPE.GetUserById(conexion, id);

                        if (objUser == null)
                        {
                            result.ErrorsList.Add("Record not found.");
                        }
                        else
                        {
                            result.Success = true;
                            result.Other   = objUser;
                        }
                    }
                    catch (Exception error)
                    {
                        throw new Exception(error.Message);
                    }
                }
            }

            return(result);
        }