Exemplo n.º 1
0
        public ResponseView SubmitFeedback(IEnumerable <SubscriptionForFeedbackView> subscriptions, string loginName, string feedbackState, string remark)
        {
            //回告意见
            var sugg = feedbackState.ConvertToBool();
            //订单ID
            var ids = subscriptions.Select(t => t.SubscriptionId.ConvertToGuid());
            //回告状态
            FeedbackState state = FeedbackState.未征订;

            Enum.TryParse(feedbackState, out state);
            //返回消息
            var result = new ResponseView();
            //创建回告
            var feedback = SubscriptionService.CreateFeedback(loginName, state, remark);
            //修改订单,增加回告
            var subs = _subscriptionRepo.Find(t => ids.Contains(t.ID));

            foreach (var item in subs)
            {
                //添加回告
                item.Feedback = feedback;
                //修改订单状态
                item.SubscriptionState = state;
                _subscriptionRepo.Modify(item);
            }
            //_subscriptionRepo.Modify(
            //    t => ids.Contains(t.ID),
            //    d => new Subscription { Feedback = feedback }
            //    );
            try
            {
                _subscriptionRepo.Context.Commit();
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message   = "回告失败";
            }
            return(result);
        }