public string SendMail(MailViewModel mailObj) { OperationsStatusViewModel OperationsStatusViewModelObj = new OperationsStatusViewModel(); OrderViewModel orderObj = new OrderViewModel(); try { bool status = _mailBusiness.Send(Mapper.Map <MailViewModel, Mail>(mailObj)); if (status) { orderObj.ID = mailObj.OrderID; orderObj.OrderStatus = "2"; _orderBusiness.CancelOrder(Mapper.Map <OrderViewModel, Order>(orderObj)); OperationsStatusViewModelObj.StatusCode = 1; OperationsStatusViewModelObj.StatusMessage = ConstObj.OrderconfirmSuccess; return(JsonConvert.SerializeObject(new { Result = "OK", Records = OperationsStatusViewModelObj })); } else { OperationsStatusViewModelObj.StatusCode = 0; OperationsStatusViewModelObj.StatusMessage = ConstObj.MailNotsend; return(JsonConvert.SerializeObject(new { Result = "ERROR", Records = OperationsStatusViewModelObj })); } } catch (Exception ex) { return(JsonConvert.SerializeObject(new { Result = "", Message = ex.Message })); } }
public OperationsStatus OrderInvoiceAndEmail(Order orderObj) { OperationsStatus operationsStatusObj = null; try { string OrderID = orderObj.ID.ToString(); //get orderheader and details by ID. orderObj = _orderRepository.GetOrderDetails(OrderID); orderObj.commonObj = new LogDetails(); orderObj.commonObj.CreatedBy = _commonBusiness.GetUA().UserName; orderObj.commonObj.CreatedDate = _commonBusiness.GetCurrentDateTime(); List <OrderDetail> OrderDetailsLists = new List <OrderDetail>(); OrderDetailsLists = _orderRepository.GetAllOrdersList(orderObj.ID.ToString()); orderObj.OrderDetailsList = OrderDetailsLists; //then call insert invoice Invoice invoiceObj = new Invoice(); invoiceObj.ParentID = orderObj.ID; invoiceObj.PaymentStatus = orderObj.PayStatusCode; invoiceObj.ParentType = "Order"; invoiceObj.LogDetails = orderObj.commonObj; operationsStatusObj = _invoiceBusiness.InsertInvoice(invoiceObj); if (operationsStatusObj.StatusCode == 1) { // send invoice to email string mailcontent = _mailBusiness.GetInvoiceTemplate(Int16.Parse(OrderID)); Mail mailObj = new Mail(); mailObj.CustomerEmail = orderObj.CustomerEmail; mailObj.MailSubject = "Invocie"; mailObj.CustomerName = orderObj.CustomerName; mailObj.TemplateString = mailcontent; bool mailstatus = _mailBusiness.Send(mailObj); //not returning mail status } } catch (Exception ex) { throw ex; } return(operationsStatusObj); }