示例#1
0
        public virtual ActionResult RequestFeedbacks(string orderIds)
        {
            LogI("RequestFeedbacks, orderIds=" + orderIds);

            var by      = AccessManager.UserId;
            var company = AccessManager.Company;

            ValueResult <List <string> > result = ValueResult <List <string> > .Success(
                "Message has been successfully sent",
                new List <string>());

            var ids = orderIds.Split(", ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            foreach (var orderId in ids)
            {
                try
                {
                    var emailService = new EmailService(LogService, SettingsBuilder.GetSmtpSettingsFromCompany(company), AddressService);

                    var sendResult = OrderFeedbackViewModel.SendFeedback(Db,
                                                                         emailService,
                                                                         orderId,
                                                                         Time.GetUtcTime(),
                                                                         by);

                    if (sendResult.Status == CallStatus.Success)
                    {
                        result.Data.Add(orderId);
                    }
                }
                catch (Exception ex)
                {
                    LogE("RequestFeedbacks", ex);
                }
            }

            return(new JsonResult()
            {
                Data = result,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
示例#2
0
        public virtual ActionResult RequestFeedback(string orderId)
        {
            LogI("RequestFeedback, orderId=" + orderId);

            ValueResult <List <string> > result;

            try
            {
                var by           = AccessManager.UserId;
                var company      = AccessManager.Company;
                var emailService = new EmailService(LogService, SettingsBuilder.GetSmtpSettingsFromCompany(company), AddressService);

                var sendResult = OrderFeedbackViewModel.SendFeedback(Db,
                                                                     emailService,
                                                                     orderId,
                                                                     Time.GetUtcTime(),
                                                                     by);

                if (sendResult.Status == CallStatus.Success)
                {
                    result = ValueResult <List <string> > .Success("Message has been successfully sent", new List <string>() { orderId });
                }
                else
                {
                    result = ValueResult <List <string> > .Error("Can't send email. Details: " + sendResult.Message);
                }
            }
            catch (Exception ex)
            {
                LogE("RequestFeedback", ex);
                result = ValueResult <List <string> > .Error("Can't send email. Error=" + ex.Message);
            }

            return(new JsonResult
            {
                Data = result,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }