public ClientRatingModel GetClientRatingByJobId(int JobId) { //unitOfWork.StartTransaction(); ClientRatingRepository repo = new ClientRatingRepository(unitOfWork); ClientRatingModel ratingModel = new ClientRatingModel(); ClientRating rating = new ClientRating(); AutoMapper.Mapper.Map(ratingModel, rating); rating = repo.GetAll().Where(x => x.JobId == JobId).FirstOrDefault(); //unitOfWork.Commit(); AutoMapper.Mapper.Map(rating, ratingModel); return ratingModel; }
public ClientRatingModel SaveClientRating(ClientRatingModel model) { //unitOfWork.StartTransaction(); ClientRatingRepository repo = new ClientRatingRepository(unitOfWork); ClientRating rating = new ClientRating(); AutoMapper.Mapper.Map(model, rating); repo.Insert(rating); //unitOfWork.Commit(); AutoMapper.Mapper.Map(rating, model); return model; }
public ClientRatingModel UpadteClientRating(ClientRatingModel model) { //unitOfWork.StartTransaction(); ClientRatingRepository repo = new ClientRatingRepository(unitOfWork); ClientRating rating = new ClientRating(); rating = repo.GetAll().Where(x => x.ClientRatingId == model.ClientRatingId).FirstOrDefault(); AutoMapper.Mapper.Map(model, rating); repo.Update(rating); //unitOfWork.Commit(); AutoMapper.Mapper.Map(rating, model); return model; }
public static decimal GetTotalFeedbackForClient(ClientRatingModel model) { decimal totalRating; int maxRating = Constants.MAX_RATING; totalRating =Math.Ceiling(Convert.ToDecimal((Constants.RATING_FOR_CORPORATION * model.Corporation / maxRating + Constants.RATING_FOR_COMMUNICATION * model.Communication / maxRating + Constants.RATING_FOR_UNDERSTANDING * model.UnderStanding / maxRating + Constants.RATING_FOR_BEHAVIOUR * model.Behaivor / maxRating + Constants.RATING_FOR_FRIENDLINESS * model.FriendLiness / maxRating + Constants.RATING_FOR_OVERALLSATSIFACTION * model.OverallSatisfaction / maxRating) * maxRating/100)); return totalRating; }
public IHttpActionResult GetClient(string id) { //Get Client Details RegisterClientBindingModel registerClientBindingModel = new RegisterClientBindingModel(); ClientModel clientModel = new ClientModel(); clientModel = clientService.GetClientById(id); AutoMapper.Mapper.Map(clientModel, registerClientBindingModel); var Email = UserManager.FindById(id) != null ? UserManager.FindById(id).Email : ""; var PhoneNumber = UserManager.FindById(id) != null ? UserManager.FindById(id).PhoneNumber : ""; registerClientBindingModel.Email = Email; registerClientBindingModel.PhoneNumber = PhoneNumber; //clientModel.FirstName = CommonFunctions.ReadResourceValue(clientModel.FirstName); //clientModel.LastName = CommonFunctions.ReadResourceValue(clientModel.LastName); //clientModel.NationalIdNumber = CommonFunctions.ReadResourceValue(clientModel.NationalIdNumber); //get rating for client List<ClientRatingBindingModel> clientRatingBindingModel = new List<ClientRatingBindingModel>(); List<ClientRatingModel> clientRatingModel = new List<ClientRatingModel>(); List<JobBindingModel> jobBindingModel = new List<JobBindingModel>(); List<JobModel> jobModel = new List<JobModel>(); AutoMapper.Mapper.Map(jobBindingModel, jobModel); jobModel = jobService.GetJobListByClientId(id); AutoMapper.Mapper.Map(jobModel, jobBindingModel); //Get employee Info for job ClientRatingModel ratingModel = new ClientRatingModel(); string[] jobIds = jobBindingModel.Select(u => u.JobId.ToString()).ToArray(); clientRatingModel = clientRatingService.GetClientRatingListByJobIds(jobIds); if (clientRatingModel.Count >0) { ratingModel.Behaivor = Convert.ToInt32(clientRatingModel.Select(c => c.Behaivor).Average()); ratingModel.Communication = Convert.ToInt32(clientRatingModel.Select(c => c.Communication).Average()); ratingModel.Corporation = Convert.ToInt32(clientRatingModel.Select(c => c.Corporation).Average()); ratingModel.FriendLiness = Convert.ToInt32(clientRatingModel.Select(c => c.FriendLiness).Average()); ratingModel.OverallSatisfaction = Convert.ToInt32(clientRatingModel.Select(c => c.OverallSatisfaction).Average()); ratingModel.UnderStanding = Convert.ToInt32(clientRatingModel.Select(c => c.UnderStanding).Average()); } ratingModel.TotalRating = CommonFunctions.GetTotalFeedbackForClient(ratingModel); //Get Location of client UserLocationModel model = locationService.FindLocationById(id); // registerClientBindingModel.ClientRatingModelList = clientRatingModel; registerClientBindingModel.AverageRating = ratingModel.TotalRating; registerClientBindingModel.UserLocationModel = model; return Ok(registerClientBindingModel); }
public IHttpActionResult SaveFeedback(ClientRatingBindingModel model) { try { ClientRatingModel clientRatingModel = new ClientRatingModel(); AutoMapper.Mapper.Map(model, clientRatingModel); clientRatingModel = clientRatingService.SaveClientRating(clientRatingModel); AutoMapper.Mapper.Map(clientRatingModel, model); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); return BadRequest(ex.Message); } return Json(model); }