public ResponseModel <int> PostRiceDateFeedback(RiceDateFeedbackDTO riceDateFeedbackDTO) { var result = new ResponseModel <int>(); result.error_code = Result.SUCCESS; if (riceDateFeedbackDTO.UserId <= 0) { result.error_code = Result.ERROR; result.message = "用户Id无效"; return(result); } else if (riceDateFeedbackDTO.RiceDateId <= 0) { result.error_code = Result.ERROR; result.message = "约饭Id无效"; return(result); } else { var riceDate = _riceDateService.GetById(riceDateFeedbackDTO.RiceDateId); var riceDateUser = _riceDateUserService.GetByUserIdAndRiceDateId(riceDateFeedbackDTO.UserId, riceDateFeedbackDTO.RiceDateId); if (riceDate.BeginDate <= System.DateTime.Now) { result.error_code = Result.ERROR; result.message = "约饭未结束无法评价"; return(result); } else if (riceDateUser.ApplyStatus == (int)EnumHelp.RiceDateApplyStatus.申请通过) { var insertResult = _riceDateFeedbackService.Insert(new RiceDateFeedback() { RiceDateId = riceDateFeedbackDTO.RiceDateId, UserId = riceDateFeedbackDTO.UserId, Content = riceDateFeedbackDTO.Content, CreateTime = System.DateTime.Now, EditTime = System.DateTime.Now }); result.data = insertResult.RiceDateFeedbackId; } } return(result); }
public ResponseModel <int> JoinRiceDate(RiceDateUserDTO riceDateUserDTO) { var result = new ResponseModel <int>(); result.error_code = Result.SUCCESS; if (riceDateUserDTO.RiceDateId <= 0) { result.error_code = Result.ERROR; result.message = "约饭Id有误"; } else if (riceDateUserDTO.UserId <= 0) { result.error_code = Result.ERROR; result.message = "用户Id有误"; } else { var riceDate = _riceDateService.GetById(riceDateUserDTO.RiceDateId); var user = _userService.GetById(riceDateUserDTO.UserId); var riceDateUser = _riceDateUserService.GetByUserIdAndRiceDateId(riceDateUserDTO.UserId, riceDateUserDTO.RiceDateId); var riceDateUserList = _riceDateUserService.GetByRiceDateId(riceDateUserDTO.RiceDateId); if (riceDate == null) { result.error_code = Result.ERROR; result.message = "约饭信息不存在"; } else if (riceDate.Status == (int)EnumHelp.EnabledEnum.无效 || riceDate.IsDelete == (int)EnumHelp.IsDeleteEnum.已删除) { result.error_code = Result.ERROR; result.message = "该约饭信息无效"; } else if (user == null) { result.error_code = Result.ERROR; result.message = "用户不存在"; } else if (user.Status == (int)EnumHelp.EnabledEnum.无效 || user.IsDelete == (int)EnumHelp.IsDeleteEnum.已删除) { result.error_code = Result.ERROR; result.message = "用户无效"; } else if (riceDateUser != null) { result.error_code = Result.ERROR; result.message = "该用户已报名过此约饭"; } else if (riceDateUserList != null && riceDateUserList.Count >= riceDate.UserCount) { result.error_code = Result.ERROR; result.message = "报名人数已满"; } else { var insertResult = _riceDateUserService.Insert(new RiceDateUser() { CreateTime = System.DateTime.Now, EditTime = System.DateTime.Now, RiceDateId = riceDateUserDTO.RiceDateId, UserId = riceDateUserDTO.UserId, ApplyStatus = (int)EnumHelp.RiceDateApplyStatus.申请中 }); result.data = insertResult.RiceDateUserId; } } return(result); }
public ResponseModel <RiceDateDetailDTO> GetRiceDateDetail([FromUri] int UserId, int RiceDateId) { var result = new ResponseModel <RiceDateDetailDTO>(); var data = new RiceDateDetailDTO(); result.error_code = Result.SUCCESS; if (RiceDateId <= 0) { result.error_code = Result.ERROR; result.message = "约饭信息ID无效"; return(result); } var riceDate = _riceDateService.GetById(RiceDateId); if (riceDate.IsDelete == (int)EnumHelp.IsDeleteEnum.效 && riceDate.Status == (int)EnumHelp.EnabledEnum.效) { data.Address = riceDate.Address; data.Age = riceDate.Age; data.BeginDate = riceDate.BeginDate; data.BusinessName = riceDate.BusinessName; data.NickName = riceDate.User != null ? riceDate.User.NickName : ""; data.PayWay = riceDate.PayWay; data.Remark = riceDate.Remark; data.RiceDateId = riceDate.RiceDateId; data.Sex = riceDate.Sex; data.Taste = riceDate.Taste; data.UserImage = riceDate.User == null ? "" : (riceDate.User.BaseImage == null ? "" : riceDate.User.BaseImage.Source + riceDate.User.BaseImage.Path); data.Zone = riceDate.Zone; data.UseCount = riceDate.UserCount; var riceDateUserList = _riceDateUserService.GetByUserId(riceDate.UserId); data.DateCount = riceDateUserList.Count; string[] ids = riceDate.BaseImageIds.Split(',').ToArray(); int[] output = Array.ConvertAll <string, int>(ids, delegate(string s) { return(int.Parse(s)); }); var baseImageList = _baseImageService.GetByIds(output); List <string> imageList = new List <string>(); if (baseImageList != null && baseImageList.Count > 0) { foreach (var item in baseImageList) { imageList.Add(item == null ? "" : item.Source + item.Path); } } data.ImagePath = imageList; ///投诉 var riceDateFeedbacklist = _riceDateFeedbackService.GetByUserId(riceDate.UserId); var complainList = new List <ComplainDetail>(); if (riceDateFeedbacklist != null && riceDateFeedbacklist.Count > 0) { data.ComplainCount = riceDateFeedbacklist.Count; foreach (var item in riceDateFeedbacklist) { complainList.Add(new ComplainDetail() { NickName = item.User == null ? "" : item.User.NickName, Content = item.Content }); } } data.ComplainDetailList = complainList; //是否已经报名 var riceDateUser = _riceDateUserService.GetByUserIdAndRiceDateId(UserId, RiceDateId); if (riceDateUser != null) { data.IsDate = 1; } if (riceDate.BeginDate >= System.DateTime.Now && riceDateUser.ApplyStatus == (int)EnumHelp.RiceDateApplyStatus.申请通过) { data.IsComplain = 1; } int age = 0; if (riceDate.User.BirthDay != null) { var BirthDay = DateTime.Parse(riceDate.User.BirthDay.ToString()); age = System.DateTime.Now.Year - BirthDay.Year; } data.Uage = age; data.Usex = string.IsNullOrWhiteSpace(riceDate.User.Sex.ToString()) ? 0 : int.Parse(riceDate.User.Sex.ToString()); } else { result.error_code = Result.ERROR; result.message = "约饭信息无效"; } result.data = data; return(result); }