Beispiel #1
0
        public async Task <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();

                var biz = new GetListKhoPhieuBaoHanhByIdBiz(context);
                biz.PHIEUBAOHANH_IDS = _phieuBaoHanhId.ToString();
                biz.LOGIN_ID         = _LoginId;

                var result = await biz.Execute();

                dynamic _metaData = new System.Dynamic.ExpandoObject();

                return(ActionHelper.returnActionResult(HttpStatusCode.OK, result, _metaData));
            }
            catch (BaseException ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
        }
Beispiel #2
0
        public async Task <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();

                var biz = new GetListKhoPhieuBaoHanhByIdBiz(context);
                biz.PHIEUBAOHANH_IDS = _phieuBaoHanhId.ToString();
                biz.LOGIN_ID         = _LoginId;
                var result = await biz.Execute();

                if (result.Count() > 0)
                {
                    /*
                     * foreach (IDictionary<string, object> row in result)
                     * {
                     *  foreach (var pair in row)
                     *  {
                     *      Console.WriteLine("  {0} = {1}", pair.Key, pair.Value);
                     *  }
                     * }   */

                    System.Text.StringBuilder strBody = new System.Text.StringBuilder();

                    MailMessage mail       = new MailMessage();
                    SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com", 587);
                    SmtpServer.EnableSsl             = true;
                    SmtpServer.Timeout               = 10000;
                    SmtpServer.DeliveryMethod        = SmtpDeliveryMethod.Network;
                    SmtpServer.UseDefaultCredentials = false;
                    SmtpServer.Credentials           = new NetworkCredential("*****@*****.**", "*837258*");

                    mail.From = new MailAddress("*****@*****.**");
                    mail.To.Add(email);// "*****@*****.**");
                    mail.Subject = "Test Mail";

                    strBody.Append(phieuBaoHanh);
                    strBody.Append(chiTietPhieuBaoHanh);
                    mail.Body = strBody.ToString();

                    SmtpServer.Send(mail);
                }
                if (string.IsNullOrEmpty(biz.MESSAGE) == false)
                {
                    throw new BaseException(biz.MESSAGE.Split('|')[2]);
                }

                dynamic _metaData = new System.Dynamic.ExpandoObject();

                return(ActionHelper.returnActionResult(HttpStatusCode.OK, result, _metaData));
            }
            catch (BaseException ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
        }