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)); } }
public static void ChangeApproval(LocalUserRating rate) { using (var dbcontext = new KaamShaamEntities()) { var dbobj = dbcontext.UserRatings.FirstOrDefault(fd => fd.Id == rate.Id); if (dbobj != null) { dbobj.IsApproved = rate.IsApproved; } dbcontext.SaveChanges(); } }
public static LocalUserRating GetRatingByJobId(long jobid) { using (var dbcontext = new KaamShaamEntities()) { var newRatings = new LocalUserRating(); var ratnigs = dbcontext.UserRatings.FirstOrDefault(r => r.JobId == jobid); if (ratnigs != null) { newRatings = ratnigs.Mapper() ; } return(newRatings); } }
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)); }
public static void AddRating(LocalUserRating source) { using (var dbcontext = new KaamShaamEntities()) { var obj = new UserRating { DateTime = DateTime.Now, IsApproved = false, JobId = source.JobId, EditedAt = DateTime.Now, Comments = source.Comments, RatedBy = source.RatedBy, RatedTo = source.RatedTo, Rating = source.Rating }; dbcontext.UserRatings.Add(obj); dbcontext.SaveChanges(); // return obj.Mapper(); } }
public JsonResult ChangeRatingApproval(LocalUserRating obj) { UserRatingService.ChangeApproval(obj); return(Json(true, JsonRequestBehavior.AllowGet)); }