using Znyc.CloudCar.Auth.HttpContextUser; using Znyc.CloudCar.IRepository.Feedback; using Znyc.CloudCar.IServices.Feedback; using Znyc.CloudCar.Model.Dtos.Feedback; using Znyc.CloudCar.Model.Entities; using Znyc.CloudCar.Model.ViewModels.ReportsCallBack; namespace Znyc.CloudCar.Services.Feedback { public class FeedbackService : IFeedbackService { private readonly IFeedbackRepository _feedbackRepository; private readonly IHttpContextUser _httpContextUser; private readonly IFeedbackPicRepository _feedbackPicRepository; public FeedbackService( IFeedbackRepository feedbackRepository, IHttpContextUser httpContextUser, IFeedbackPicRepository feedbackPicRepository ) { _feedbackRepository = feedbackRepository; _httpContextUser = httpContextUser; _feedbackPicRepository = feedbackPicRepository; _feedbackPicRepository = feedbackPicRepository; } /// /// 新增意见反馈 /// /// /// public async Task AddFeedbackAsync(FeedbackAddInput input) { FeedbackEntity entity = new FeedbackEntity { UserId = _httpContextUser.Id, Content = input.Content, State = 0, Result = "", Note = "" }; entity = await _feedbackRepository.InsertAsync(entity); for (int i = 0; i < input.FeedbackPic.Count; i++) { FeedbackPicEntity feedbackPicEntity = new FeedbackPicEntity { FeedbackId = entity.Id, PicUrl = input.FeedbackPic[i], Sort = i + 1, IsEnabled = true, }; await _feedbackPicRepository.InsertAsync(feedbackPicEntity); } ResponseOutput response = new ResponseOutput() { Msg = "反馈成功!", Successed = true, Code = 1 }; return response; } } }