public IHttpActionResult Get(string id)
        {
            UserRatingService companyRatingService = CreateUserRatingService();
            var rating = companyRatingService.GetUserRatingById(id);

            return(Ok(rating));
        }
        public IHttpActionResult Get()
        {
            UserRatingService userRatingService = CreateUserRatingService();
            var ratings = userRatingService.GetUserRatings();

            return(Ok(ratings));
        }
示例#3
0
        public HttpResponseMessage CloseJob(CloseJobApiModel model)
        {
            try
            {
                #region not mapped
                if (model == null || string.IsNullOrEmpty(model.Comments) || string.IsNullOrEmpty(model.RatedBy) ||
                    string.IsNullOrEmpty(model.RatedTo) ||
                    model.Rating < 0.0 ||
                    model.JobId < 0.0)
                {
                    var response = new ApiResponseModel
                    {
                        Data    = null,
                        Message = "Data is not mapped",
                        Success = false
                    };
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, response));
                }
                #endregion

                #region obj
                var rating = new LocalUserRating
                {
                    DateTime   = DateTime.Now,
                    IsApproved = false,
                    JobId      = model.JobId,
                    Comments   = model.Comments,
                    RatedBy    = model.RatedBy,
                    RatedTo    = model.RatedTo,
                    Rating     = model.Rating
                };
                #endregion

                UserRatingService.AddRating(rating);
                if (rating.JobId > 0)
                {
                    JobService.MarkJobDone(rating.JobId, rating.RatedTo);
                }
                var res = new ApiResponseModel
                {
                    Data    = model,
                    Message = "Job Closed.",
                    Success = true
                };
                return(Request.CreateResponse(HttpStatusCode.OK, res));
            }
            catch (Exception excep)
            {
                var response = new ApiResponseModel
                {
                    Data    = null,
                    Message = excep.InnerException.Message,
                    Success = false
                };
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, response));
            }
        }
示例#4
0
        public HttpResponseMessage FeedBack(ApiRequestModel model)
        {
            try
            {
                #region not mapped
                if (model == null || string.IsNullOrEmpty(model.Comments) || string.IsNullOrEmpty(model.RatedBy) ||
                    string.IsNullOrEmpty(model.RatedTo) ||
                    Math.Abs(model.Rating) < 0.0)
                {
                    var response = new ApiResponseModel
                    {
                        Data    = null,
                        Message = "Data is not mapped",
                        Success = false
                    };
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, response));
                }
                #endregion
                UserRatingService.AddRating(new LocalUserRating
                {
                    Comments = model.Comments,
                    RatedBy  = model.RatedBy,
                    RatedTo  = model.RatedTo,
                    Rating   = model.Rating
                });

                var res = new ApiResponseModel
                {
                    Data    = model,
                    Message = "Jon Feedback Posted.",
                    Success = true
                };
                return(Request.CreateResponse(HttpStatusCode.OK, res));
            }
            catch (Exception excep)
            {
                var response = new ApiResponseModel
                {
                    Data    = null,
                    Message = excep.InnerException.Message,
                    Success = false
                };
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, response));
            }
        }
示例#5
0
        public ActionResult AddNewRating(LocalUserRating rating)
        {
            var id = System.Web.HttpContext.Current.User.Identity.GetUserId();

            rating.RatedBy = id;
            try
            {
                rating.Rating = Convert.ToDouble(rating.TempoRating);
                UserRatingService.AddRating(rating);
                if (rating.JobId > 0)
                {
                    JobService.MarkJobDone(rating.JobId, rating.RatedTo);
                }
            }
            catch (Exception excep)
            {
            }
            return(Json(false, JsonRequestBehavior.AllowGet));
        }
示例#6
0
        public static LocalUser MapUser(this AspNetUser source)
        {
            LocalCategory cat = null;

            if (source.CategoryId != 0)
            {
                cat = CategoryService.GetCategoryById(source.CategoryId);
            }
            var roleName = source.AspNetRoles.Any() ? source.AspNetRoles.FirstOrDefault().Name : "";

            var profileVists = new List <LocalProfileVisit>();

            if (source.ProfileVisitors != null && source.ProfileVisitors.Any())
            {
                profileVists = source.ProfileVisitors.Select(prf => prf.Mapper()).ToList();
            }

            var profileRatings = new List <LocalUserRating>();

            if (source.YourRatings != null && source.YourRatings.Any())
            {
                profileRatings = source.YourRatings.Where(df => df.IsApproved).Select(prf => prf.Mapper()).ToList();
            }

            var score = UserRatingService.GetRatingsInFloat(source.Id);

            var tempoLoc = " 31.476535115002306_74.32158172130585";

            if (source.LocationCord != null)
            {
                tempoLoc = source.LocationCord.Latitude + "_" + source.LocationCord.Longitude;
            }

            var userObj = new LocalUser
            {
                CNIC     = source.CNIC ?? "(Not Provided)",
                Email    = source.Email ?? "(Not Provided)",
                FullName = source.FullName ?? "(Not Provided)",
                Id       = source.Id,
                Mobile   = source.Mobile ?? "(Not Provided)",
                Type     = source.Type ?? "(Not Provided)",
                UserName = source.UserName ?? "(Not Provided)",
                Country  = source.Country ?? "(Not Provided)",
                City     = source.City ?? "(Not Provided)",

                LocTempo = tempoLoc,

                Intro         = source.Intro ?? "(Not Provided)",
                Language      = source.Language ?? "(Not Provided)",
                Status        = (bool)source.Status,
                ContractorId  = source.ContractorId ?? "(Not Provided)",
                CategoryId    = source.CategoryId ?? 0,
                RoleName      = roleName ?? "(Not Provided)",
                IsApproved    = (bool)source.IsApproved,
                Feedback      = source.Feedback ?? " - ",
                LocationName  = source.LocationName ?? "(Not Provided)",
                lat           = (source.LocationCord.Latitude).ToString(),
                lng           = (source.LocationCord.Longitude).ToString(),
                CatName       = cat?.Name ?? "(Not Provided)",
                Location      = source.LocationCord,
                Password      = source.PasswordHash,
                EditedAt      = Convert.ToDateTime(source.EditedAt).ToLongDateString(),
                EditedAtObj   = Convert.ToDateTime(source.EditedAt),
                ProfileVisits = profileVists,
                Score         = score,
                UserRatings   = profileRatings,
                CanRate       = false
            };

            return(userObj);
        }
 public UserRatingsController(UserRatingService userRatingService)
 {
     this.userRatingService = userRatingService;
 }
 private UserRatingService CreateRatingService()
 {
     var reviewService = new UserRatingService(User.Identity.GetUserId());
     return reviewService;
 }
示例#9
0
 public JsonResult ChangeRatingApproval(LocalUserRating obj)
 {
     UserRatingService.ChangeApproval(obj);
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
示例#10
0
        /// <summary>
        /// for dashborad
        /// </summary>
        /// <returns></returns>
        public ActionResult UserReviews()
        {
            var data = UserRatingService.GetAllRatingsForDash();

            return(View(data));
        }
示例#11
0
        public static LocalUser MapUser(this AspNetUser source)
        {
            if (source == null)
            {
                return(null);
            }

            var userRoles = new List <string>();

            try
            {
                if (source.AspNetRoles != null && source.AspNetRoles.Any())
                {
                    userRoles = source.AspNetRoles.Select(ro => ro.Name).ToList();
                }
            }
            catch (Exception gf) {}

            LocalCategory cat = null;

            if (source.CategoryId != null && source.CategoryId != 0)
            {
                cat = CategoryService.GetCategoryById(source.CategoryId);
            }
            LocalUser contract = null;

            if (!string.IsNullOrEmpty(source.ContractorId))
            {
                contract = UserServices.GetUserById(source.ContractorId); //company
            }

            var profileVists = new List <LocalProfileVisit>();

            try
            {
                if (source.ProfileVisitors != null && source.ProfileVisitors.Any())
                {
                    profileVists = source.ProfileVisitors.Select(prf => prf.Mapper()).ToList();
                }
            }
            catch (Exception sds)  {}

            var profileRatings = new List <LocalUserRating>();

            try
            {
                if (source.YourRatings != null && source.YourRatings.Any())
                {
                    profileRatings = source.YourRatings.Where(df => df.IsApproved).Select(prf => prf.Mapper()).ToList();
                }
            }
            catch (Exception)  { }

            var score = UserRatingService.GetRatingsInFloat(source.Id);

            var jobHistories = new List <CustomJobHistory>();

            try
            {
                if (source.JobHistories != null && source.JobHistories.Any())
                {
                    jobHistories = source.JobHistories.Select(prf => prf.Mapper()).ToList();
                }
            }
            catch (Exception) { }

            var tempoLoc = " 31.476535115002306_74.32158172130585";

            if (source.LocationCord != null)
            {
                tempoLoc = source.LocationCord.Latitude + "_" + source.LocationCord.Longitude;
            }
            return(new LocalUser
            {
                Location = source.LocationCord,

                CategoryName = cat?.Name ?? "",
                CompanyName = contract?.FullName ?? "",
                ProfileVisits = profileVists,
                LocTempo = tempoLoc,
                Score = score,
                UserRatings = profileRatings,
                ProfileImg = "",


                CNIC = source.CNIC ?? "(Not Provided)",
                Email = source.Email ?? "(Not Provided)",
                FullName = source.FullName ?? "(Not Provided)",
                Id = source.Id,
                Mobile = source.Mobile ?? "(Not Provided)",
                Type = source.Type ?? "(Not Provided)",
                UserName = source.UserName ?? "(Not Provided)",
                Country = source.Country ?? "(Not Provided)",
                City = source.City ?? "(Not Provided)",

                Intro = source.Intro ?? " ",
                Language = source.Language ?? " ",
                ContractorId = source.ContractorId ?? "(Not Provided)",
                CategoryId = source.CategoryId ?? 0,
                LocationName = source.LocationName ?? "(Not Provided)",
                JobHistories = jobHistories,
                CanRate = false,
                Roles = userRoles,
                PhoneNumberConfirmed = source.PhoneNumberConfirmed,
                Feedback = source.Feedback
            });
        }
        private UserRatingService CreateUserRatingService()
        {
            var userRatingService = new UserRatingService();

            return(userRatingService);
        }