Пример #1
0
 public static TMD.Web.Models.InquiryDetailModel MapServerToClient(this InquiryDetail source)
 {
     return(new TMD.Web.Models.InquiryDetailModel
     {
         InquiryID = source.InquiryID,
         InquiryDetailID = source.InquiryDetailID,
         ProductID = source.ProductID
     });
 }
Пример #2
0
        private List <InquiryDetail> GetChildOnCreate(Inquiry master, InquiryComplex source)
        {
            List <InquiryDetail> infos = new List <InquiryDetail>();
            var wanted = source.ChildList.Where(x => x.IsDirty == true);

            foreach (var item in wanted)
            {
                InquiryDetail temp = Mapper.Map <InquiryDetail>(item);
                temp.InquiryID  = master.InquiryID;
                temp.LastPerson = IdentityService.GetUserData().UserID;
                temp.LastUpdate = DateTime.Now;
                infos.Add(temp);
            }
            return(infos);
        }
        public HttpResponseMessage SaveInformation(InquiryDetail allDataobj)
        {
            ShaligramConsultancyEntities objEntities = new ShaligramConsultancyEntities();
            InquiryDetail objinqiry = new InquiryDetail();

            objinqiry.Name        = allDataobj.Name;
            objinqiry.Email       = allDataobj.Email;
            objinqiry.Phone       = allDataobj.Phone;
            objinqiry.EMI         = allDataobj.EMI;
            objinqiry.Rupees      = allDataobj.Rupees;
            objinqiry.InquiryFor  = allDataobj.InquiryFor;
            objinqiry.CreatedDate = DateTime.Now;
            objEntities.InquiryDetails.Add(objinqiry);
            objEntities.SaveChanges();


            //Image Path
            var imagepath = System.Configuration.ConfigurationManager.AppSettings["tempLogo"];
            //owner mail
            var mappedPath = HttpContext.Current.Server.MapPath("~/EmailTemplate/EmailTemplate.html");

            string bodyTemplate = System.IO.File.ReadAllText(mappedPath);

            //string ToEmail = "[email protected],[email protected]";
            bodyTemplate = bodyTemplate.Replace("[@Name]", allDataobj.Name);
            bodyTemplate = bodyTemplate.Replace("[@Email]", allDataobj.Email);
            bodyTemplate = bodyTemplate.Replace("[@Phone]", allDataobj.Phone);
            bodyTemplate = bodyTemplate.Replace("[@EnquiryFor]", allDataobj.InquiryFor);
            bodyTemplate = bodyTemplate.Replace("[@Path]", imagepath);
            EmailHelper.SendAsyncEmail("", "[Shaligram Consultancy] Receive New Enquiry For - " + allDataobj.InquiryFor, bodyTemplate, true);

            //thank u email
            var    mappedPathThankU     = HttpContext.Current.Server.MapPath("~/EmailTemplate/ThankuEmail.html");
            string bodyTemplateThankYou = System.IO.File.ReadAllText(mappedPathThankU);

            bodyTemplateThankYou = bodyTemplateThankYou.Replace("[@Name]", allDataobj.Name);
            bodyTemplateThankYou = bodyTemplateThankYou.Replace("[@EnquiryFor]", allDataobj.InquiryFor);
            bodyTemplateThankYou = bodyTemplateThankYou.Replace("[@Email]", allDataobj.Email);
            bodyTemplateThankYou = bodyTemplateThankYou.Replace("[@Phone]", allDataobj.Phone);
            bodyTemplateThankYou = bodyTemplateThankYou.Replace("[@Path]", imagepath);
            EmailHelper.SendAsyncEmail(allDataobj.Email, "Thank You For Your Inquiry With Shaligram Consultancy.", bodyTemplateThankYou, true);



            return(Request.CreateResponse(HttpStatusCode.OK, true));
        }
Пример #4
0
        public void RemoveChild(long id)
        {
            #region 取資料
            InquiryDetail query = this._DetailRepository.Get(x => x.SeqNo == id);
            #endregion

            #region 邏輯驗證
            if (query == null)//沒有資料
            {
                throw new Exception("MessageNoData".ToLocalized());
            }

            #endregion

            #region 變為Models需要之型別及邏輯資料

            #endregion

            #region Models資料庫
            this._DetailRepository.Delete(query);
            this._UnitOfWork.SaveChange();
            #endregion
        }
Пример #5
0
        public async Task <IActionResult> SummaryPost(ProductUserVM ProductUserVM)
        {
            var ClaimIdentity = (ClaimsIdentity)User.Identity;
            var Claim         = ClaimIdentity.FindFirst(ClaimTypes.NameIdentifier);

            var PathToTemplate = _webHostEnvironment.WebRootPath + Path.DirectorySeparatorChar.ToString()
                                 + "templates" + Path.DirectorySeparatorChar.ToString() +
                                 "Inquiry.html";

            var    subject  = "New Inquiry";
            string HtmlBody = "";

            using (StreamReader sr = System.IO.File.OpenText(PathToTemplate))
            {
                HtmlBody = sr.ReadToEnd();
            }
            //Name: { 0}
            //Email: { 1}
            //Phone: { 2}
            //Products: {3}

            StringBuilder productListSB = new StringBuilder();

            foreach (var prod in ProductUserVM.ProductList)
            {
                productListSB.Append($" - Name: { prod.Name} <span style='font-size:14px;'> (ID: {prod.Id})</span><br />");
            }

            string messageBody = string.Format(HtmlBody,
                                               ProductUserVM.ApplicationUser.FullName,
                                               ProductUserVM.ApplicationUser.Email,
                                               ProductUserVM.ApplicationUser.PhoneNumber,
                                               productListSB.ToString());


            await _emailSender.SendEmailAsync(WC.EmailAdmin, subject, messageBody);

            InquiryHeader inquiryHeader = new InquiryHeader()
            {
                ApplicationUserId = Claim.Value,
                FullName          = ProductUserVM.ApplicationUser.FullName,
                Email             = ProductUserVM.ApplicationUser.Email,
                PhoneNumber       = ProductUserVM.ApplicationUser.PhoneNumber,
                InquiryDate       = DateTime.Now
            };

            _InHRepo.Add(inquiryHeader);
            _InHRepo.Save();

            foreach (var prod in ProductUserVM.ProductList)
            {
                InquiryDetail inquiryDetail = new InquiryDetail()
                {
                    InquiryHeaderId = inquiryHeader.Id,
                    ProductId       = prod.Id
                };
                _InDRepo.Add(inquiryDetail);
            }

            _InDRepo.Save();

            return(RedirectToAction(nameof(InquiryConfirmation)));
        }
Пример #6
0
        public async Task <IActionResult> SummaryPost(IFormCollection collection, ProductUserVM ProductUserVM)
        {
            var claimsIdentity = (ClaimsIdentity)User.Identity;
            var claim          = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);

            if (User.IsInRole(WC.AdminRole))
            {
                //we need to create an order
                //var orderTotal = 0.0;
                //foreach(Product prod in ProductUserVM.ProductList)
                //{
                //    orderTotal += prod.Price * prod.TempSqFt;
                //}
                OrderHeader orderHeader = new OrderHeader()
                {
                    CreatedByUserId = claim.Value,
                    FinalOrderTotal = ProductUserVM.ProductList.Sum(x => x.TempSqFt * x.Price),
                    City            = ProductUserVM.ApplicationUser.City,
                    StreetAddress   = ProductUserVM.ApplicationUser.StreetAddress,
                    State           = ProductUserVM.ApplicationUser.State,
                    PostalCode      = ProductUserVM.ApplicationUser.PostalCode,
                    FullName        = ProductUserVM.ApplicationUser.FullName,
                    Email           = ProductUserVM.ApplicationUser.Email,
                    PhoneNumber     = ProductUserVM.ApplicationUser.PhoneNumber,
                    OrderDate       = DateTime.Now,
                    OrderStatus     = WC.StatusPending
                };
                _orderHRepo.Add(orderHeader);
                _orderHRepo.Save();

                foreach (var prod in ProductUserVM.ProductList)
                {
                    OrderDetail orderDetail = new OrderDetail()
                    {
                        OrderHeaderId = orderHeader.Id,
                        PricePerSqFt  = prod.Price,
                        Sqft          = prod.TempSqFt,
                        ProductId     = prod.Id
                    };
                    _orderDRepo.Add(orderDetail);
                }
                _orderDRepo.Save();

                string nonceFromTheClient = collection["payment_method_nonce"];

                var request = new TransactionRequest
                {
                    Amount             = Convert.ToDecimal(orderHeader.FinalOrderTotal),
                    PaymentMethodNonce = nonceFromTheClient,
                    OrderId            = orderHeader.Id.ToString(),
                    Options            = new TransactionOptionsRequest
                    {
                        SubmitForSettlement = true
                    }
                };

                var gateway = _brain.GetGateway();
                Result <Transaction> result = gateway.Transaction.Sale(request);

                if (result.Target.ProcessorResponseText == "Approved")
                {
                    orderHeader.TransactionId = result.Target.Id;
                    orderHeader.OrderStatus   = WC.StatusApproved;
                }
                else
                {
                    orderHeader.OrderStatus = WC.StatusCancelled;
                }
                _orderHRepo.Save();
                return(RedirectToAction(nameof(InquiryConfirmation), new { id = orderHeader.Id }));
            }
            else
            {
                //we need to create an inquiry
                var PathToTemplate = _webHostEnvironment.WebRootPath + Path.DirectorySeparatorChar.ToString()
                                     + "templates" + Path.DirectorySeparatorChar.ToString() +
                                     "Inquiry.html";

                var    subject  = "New Inquiry";
                string HtmlBody = "";
                using (StreamReader sr = System.IO.File.OpenText(PathToTemplate))
                {
                    HtmlBody = sr.ReadToEnd();
                }
                //Name: { 0}
                //Email: { 1}
                //Phone: { 2}
                //Products: {3}

                StringBuilder productListSB = new StringBuilder();
                foreach (var prod in ProductUserVM.ProductList)
                {
                    productListSB.Append($" - Name: { prod.Name} <span style='font-size:14px;'> (ID: {prod.Id})</span><br />");
                }

                string messageBody = string.Format(HtmlBody,
                                                   ProductUserVM.ApplicationUser.FullName,
                                                   ProductUserVM.ApplicationUser.Email,
                                                   ProductUserVM.ApplicationUser.PhoneNumber,
                                                   productListSB.ToString());


                await _emailSender.SendEmailAsync(WC.EmailAdmin, subject, messageBody);

                InquiryHeader inquiryHeader = new InquiryHeader()
                {
                    ApplicationUserId = claim.Value,
                    FullName          = ProductUserVM.ApplicationUser.FullName,
                    Email             = ProductUserVM.ApplicationUser.Email,
                    PhoneNumber       = ProductUserVM.ApplicationUser.PhoneNumber,
                    InquiryDate       = DateTime.Now
                };

                _inqHRepo.Add(inquiryHeader);
                _inqHRepo.Save();

                foreach (var prod in ProductUserVM.ProductList)
                {
                    InquiryDetail inquiryDetail = new InquiryDetail()
                    {
                        InquiryHeaderId = inquiryHeader.Id,
                        ProductId       = prod.Id,
                    };
                    _inqDRepo.Add(inquiryDetail);
                }
                _inqDRepo.Save();
                TempData[WC.Success] = "Inquiry submitted successfully";
            }



            return(RedirectToAction(nameof(InquiryConfirmation)));
        }