public IHttpActionResult GetComments([FromUri] CommentsGetParameters commentsGetParameters) { IList <CommentsDTO> commentsDTO = _gasstationsservice.GetComments(commentsGetParameters, out ReturnValues returnValues); if (!returnValues.Error) { return(Ok(new ResponseSuccess { Success = true, Status = Convert.ToInt32(returnValues.Code), Message = returnValues.Message, Data = new { comments = commentsDTO } })); } return(Ok(new ResponseError { Success = false, Status = Convert.ToInt32(returnValues.Code), Message = returnValues.Message })); }
public IList <CommentsDTO> GetComments(CommentsGetParameters commentsGetParameters, out ReturnValues returnValues) { IList <CommentsDTO> commentsDTO = null; returnValues = new ReturnValues(); int gasstaion; try { var query = _unitOfWork.CommentRepository.QueryableObject(); if (!String.IsNullOrEmpty(commentsGetParameters.GasStationID)) { gasstaion = Convert.ToInt32(commentsGetParameters.GasStationID); query = query.Where(row => row.GasStaionID == gasstaion); } query = query.OrderByDescending(row => row.CreatedOn); commentsDTO = query.Select(row => new CommentsDTO() { ID = row.ID.ToString(), GasStaionID = row.GasStaionID.ToString(), RegistrationID = row.RegistrationID.ToString(), Comment = row.Comment1, CreatedOn = row.CreatedOn.ToString(), }).ToList(); foreach (var comment in commentsDTO) { comment.RegistrationID = GetNameComment(comment.RegistrationID); } ; returnValues.SetReturnValues(false, ErrorCodes.Ok, Utils.GetEnumDescription(ErrorCodes.Ok)); } catch (Exception ex) { returnValues.SetReturnValues(true, ErrorCodes.InternalError, ex.Message); } return(commentsDTO as IList <CommentsDTO>); }