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); }
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); }
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); }