Beispiel #1
0
        /// <summary>
        /// resends verification email
        /// </summary>
        /// <returns></returns>
        public ActionResult Verification()
        {
            var user     = MASTERdomain.organisation.users.First();
            var viewdata = new ViewDataDictionary()
            {
                { "host", MASTERdomain.ToHostName().ToDomainUrl() },
                { "confirmCode", user.confirmationCode },
                { "email", user.email }
            };

            EmailHelper.SendEmailNow(EmailViewType.ACCOUNT_CONFIRMATION, viewdata, "New Account Details and Email Verification Link",
                                     user.email, user.ToFullName(), null);
            return(new EmptyResult());
        }
Beispiel #2
0
        public ActionResult UpdateDomain(string domainName)
        {
            // custom domain
            if (!string.IsNullOrEmpty(domainName))
            {
                domainName = domainName.Replace("http://", "");
                domainName = domainName.Replace("https://", "");
                // check that domain does not already exist
                var domain = repository.GetSubDomains().Where(x => x.customDomain == domainName).SingleOrDefault();
                if (domain != null && domain.id != subdomainid.Value)
                {
                    return(Json("Domain name is currently in use".ToJsonFail()));
                }
                // check for invalid domain name
                if (domainName.EndsWith("tradelr.com"))
                {
                    return(Json("Domain name is invalid".ToJsonFail()));
                }
                // check that domain name resolves to our server ip
                try
                {
                    var addresses = Dns.GetHostAddresses(domainName).Select(x => x.ToString()).ToArray();
                    if (!addresses.Contains(GeneralConstants.SERVER_IP))
                    {
                        return
                            (Json(string.Format("{0} has not been configured to point to {1}", domainName,
                                                GeneralConstants.SERVER_IP).ToJsonFail()));
                    }
                }
                catch (Exception ex)
                {
                    Syslog.Write(ex);
                    return
                        (Json(
                             "Invalid domain name entered. Domain name should be in the format www.yourdomain.com".ToJsonFail()));
                }
            }

            MASTERdomain.customDomain = domainName;

            repository.Save();

            return(Json(MASTERdomain.ToHostName().ToDomainUrl("/login").ToJsonOKData()));
        }
Beispiel #3
0
        public ActionResult Ship(long id, string trackingno, string trackingAddress, string shippingService, string shipwire)
        {
            try
            {
                var order = repository.GetOrder(subdomainid.Value, id);
                if (order == null)
                {
                    return(Json("Order not found".ToJsonFail()));
                }

                var transaction = new Transaction(order, repository, sessionid.Value);

                if (!string.IsNullOrEmpty(shipwire))
                {
                    if (!transaction.HasValidShippingAddress())
                    {
                        return(SendJsonErrorResponse("The destination shipping address is incomplete."));
                    }
                    var shipwireService = transaction.GetShipWireService();
                    var shipwireItems   = order.ToShipwireItems();
                    var shippingMethod  = order.shipwireShippingid;
                    var address         = transaction.GetShipwireShippingAddress();
                    shipwireService.CreateOrder(transaction.GetID().ToString(), shippingMethod, shipwireItems, address);
                    var resp = shipwireService.SubmitOrder();

                    // got response?
                    if (resp == null)
                    {
                        return(SendJsonErrorResponse("No response from Shipwire. Please try again later."));
                    }

                    // check for exceptions
                    var exceptions = resp.GetExceptions();
                    if (exceptions.Count != 0)
                    {
                        return(SendJsonErrorResponse(exceptions[transaction.GetID().ToString()]));
                    }

                    // check for one order
                    var submittedOrder = resp.OrderInformation.Order[0];

                    transaction.UpdateOrderStatus(OrderStatus.SHIPPED);

                    transaction.AddShipwireTransaction(submittedOrder.number.ToString(), XElement.Parse(shipwireService.GetXmlResponse()));

                    transaction.SaveUpdatedTransaction();
                }
                else
                {
                    transaction.UpdateOrderAsShipped(shippingService, trackingno, trackingAddress);

                    // notify buyer that order has been shipped
                    var viewloc      = MASTERdomain.ToHostName().ToDomainUrl(transaction.GetOrderLink());
                    var emailContent = new OrderShippedEmailContent
                    {
                        orderNumber     = transaction.GetOrderNumber(),
                        shippingAddress = transaction.GetShippingAddress().ToHtmlString(),
                        sender          = transaction.GetOwner().ToEmailName(false),
                        viewloc         = viewloc
                    };

                    string subject = "Invoice #" + emailContent.orderNumber + " has been shipped";
                    var    msg     = new Message(transaction.GetReceiver(), transaction.GetOwner(), subdomainid.Value);
                    var    result  = msg.SendMessage(this, repository, EmailViewType.ORDER_SHIPPED, emailContent, subject, viewloc);

                    if (!result.success)
                    {
                        Syslog.Write(result.message);
                    }
                }

                return(Json("".ToJsonOKMessage()));
            }
            catch (Exception ex)
            {
                return(SendJsonErrorResponse(ex));
            }
        }