//Get public List <RatingDomain> RatingAndReviewGetByplacesId(int placesId) { List <RatingDomain> ListRatingDomain = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Rating_SelectByPlacesId" , inputParamMapper : delegate(SqlParameterCollection paramcollection) { paramcollection.AddWithValue("@placesId", placesId); }, map : delegate(IDataReader reader, short set) { RatingDomain p = new RatingDomain(); int startingIndex = 0; p.Id = reader.GetSafeInt32(startingIndex++); p.placesId = reader.GetSafeInt32(startingIndex++); p.userId = reader.GetSafeString(startingIndex++); p.Rating = reader.GetSafeDecimal(startingIndex++); p.Subject = reader.GetSafeString(startingIndex++); p.Review = reader.GetSafeString(startingIndex++); p.Created = reader.GetSafeDateTime(startingIndex++); p.reviewPointScore = reader.GetSafeInt32(startingIndex++); p.userName = reader.GetSafeString(startingIndex++); if (ListRatingDomain == null) { ListRatingDomain = new List <RatingDomain>(); } ListRatingDomain.Add(p); }); return(Decorate(ListRatingDomain)); }
//Getall public List <RatingDomain> RatingAndReviewGetAll() { List <RatingDomain> ratingsList = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Rating_SelectAll" , inputParamMapper : null , map : delegate(IDataReader reader, short set) { RatingDomain p = new RatingDomain(); int startingIndex = 0; p.Id = reader.GetSafeInt32(startingIndex++); p.placesId = reader.GetSafeInt32(startingIndex++); p.userId = reader.GetSafeString(startingIndex++); p.Rating = reader.GetSafeDecimal(startingIndex++); p.Subject = reader.GetSafeString(startingIndex++); p.Review = reader.GetSafeString(startingIndex++); p.Created = reader.GetSafeDateTime(startingIndex++); p.reviewPointScore = reader.GetSafeInt32(startingIndex++); if (ratingsList == null) { ratingsList = new List <RatingDomain>(); } ratingsList.Add(p); } ); return(ratingsList); }
public RatingDomain GetRatingDomainRatingId(int ratingId) { RatingDomain Review = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Ratings_GetPlaceIdByRatingId" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@ratingId", ratingId); } , map : delegate(IDataReader reader, short set) { Review = new RatingDomain(); int startingIndex = 0; //startingOrdinal Review.Id = reader.GetSafeInt32(startingIndex++); Review.placesId = reader.GetSafeInt32(startingIndex++); Review.userId = reader.GetSafeString(startingIndex++); Review.Rating = reader.GetSafeDecimal(startingIndex++); Review.Subject = reader.GetSafeString(startingIndex++); Review.Review = reader.GetSafeString(startingIndex++); Review.Created = reader.GetDateTime(startingIndex++); Review.reviewPointScore = reader.GetSafeInt32(startingIndex++); Review.userName = reader.GetSafeString(startingIndex++); } ); return(Review); }
public HttpResponseMessage GetRating(RatingRequest <string> request) { HttpResponseMessage responseMessage = new HttpResponseMessage(); BaseResponse <TotalRatingAPIViewModel> response = new BaseResponse <TotalRatingAPIViewModel>(); try { var domain = new RatingDomain(); //response = domain.GetRatingByProductId(product_id); response = domain.GetRatingByRequest(request); } catch (ApiException e) { // catch ApiException responseMessage.StatusCode = e.StatusCode; response = BaseResponse <TotalRatingAPIViewModel> .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus); } catch (Exception ex) { responseMessage.StatusCode = HttpStatusCode.InternalServerError; response = BaseResponse <TotalRatingAPIViewModel> .Get(false, ex.ToString(), null, ResultEnum.InternalError); } //return responseMessage.Content = new JsonContent(response); return(responseMessage); }
public HttpResponseMessage UpdateRating(RatingAPIViewModel rating) { HttpResponseMessage responseMessage = new HttpResponseMessage(); BaseResponse <RatingAPIViewModel> response = new BaseResponse <RatingAPIViewModel>(); try { var domain = new RatingDomain(); response = domain.UpdateRatingProduct(rating); } catch (ApiException e) { // catch ApiException responseMessage.StatusCode = e.StatusCode; response = BaseResponse <RatingAPIViewModel> .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus); } catch (Exception ex) { responseMessage.StatusCode = HttpStatusCode.InternalServerError; response = BaseResponse <RatingAPIViewModel> .Get(false, ex.ToString(), null, ResultEnum.InternalError); } //return responseMessage.Content = new JsonContent(response); return(responseMessage); throw new NotImplementedException(); }
public HttpResponseMessage getAvgRatingsByplacesId(int placesId) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } RatingDomain avgRating = _RatingService.avgRatingGet(placesId); ItemResponse <decimal> Response = new ItemResponse <decimal>(); Response.Item = avgRating.Rating; return(Request.CreateResponse(HttpStatusCode.OK, Response.Item)); }
public RatingDomain avgRatingGet(int placesId) { RatingDomain avgRating = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Rating_AvgRating" , inputParamMapper : delegate(SqlParameterCollection param) { param.AddWithValue("@placesId", placesId); } , map : delegate(IDataReader reader, short set) { avgRating = new RatingDomain(); int startingIndex = 0; avgRating.Rating = reader.GetSafeDecimal(startingIndex++); } ); return(avgRating); }
public HttpResponseMessage CreateSubRating(RatingAPIViewModel rating) { HttpResponseMessage responseMessage = new HttpResponseMessage(); BaseResponse <RatingAPIViewModel> response = new BaseResponse <RatingAPIViewModel>(); try { var claimPrincipal = (ClaimsPrincipal)RequestContext.Principal; // get Id from Token Claims var customerId = claimPrincipal.Claims.Where(c => c.Type == "CustomerId").Select(c => c.Value).SingleOrDefault(); int customerID = 0; Int32.TryParse(customerId, out customerID); DateTime time = DataService.Models.Utils.GetCurrentDateTime(); var domain = new RatingDomain(); rating.CreateTime = time; rating.Active = true; rating.CustomerId = customerID; response = domain.CreateSubRating(rating); } catch (ApiException e) { // catch ApiException responseMessage.StatusCode = e.StatusCode; response = BaseResponse <RatingAPIViewModel> .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus); } catch (Exception ex) { responseMessage.StatusCode = HttpStatusCode.InternalServerError; response = BaseResponse <RatingAPIViewModel> .Get(false, ex.ToString(), null, ResultEnum.InternalError); } //return responseMessage.Content = new JsonContent(response); return(responseMessage); }