public async Task <ActionResult> RefreshWishList([FromBody] WishlistList data, string username)
 {
     try
     {
         var result = _db.GetCollection <WishList>("WishList").DeleteManyAsync(Builders <WishList> .Filter.Eq("UserName", username)).Result;
         if (data.ListOfProducts.Count > 0)
         {
             data.ListOfProducts.ToList().ForEach(c => c.UserName = username);
             await _db.GetCollection <WishList>("WishList").InsertManyAsync(data.ListOfProducts);
         }
         return(Ok(new ResponseData
         {
             Code = "200",
             Message = "Inserted",
             Data = null
         }));
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("UserController", "RefreshWishList", ex.Message);
         return(BadRequest(new ResponseData
         {
             Code = "400",
             Message = "Failed",
             Data = ex.Message
         }));
     }
 }
        public async Task <ActionResult> Post([FromBody] Category category)
        {
            try
            {
                string objectName = category.ProductFor + "-" + category.ProductType + ".jpg";
                //product.MinioObject_URL = WH.GetMinioObject("products", objectName).Result;
                //product.MinioObject_URL = AH.GetAmazonS3Object("product-category", objectName);
                category.MinioObject_URL = AH.GetS3Object("product-category", objectName);
                await _db.GetCollection <Category>("Category").InsertOneAsync(category);

                return(Ok(new ResponseData
                {
                    Code = "200",
                    Message = "Inserted",
                    Data = null
                }));
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("CategoryController", "Post", ex.Message);
                return(BadRequest(new ResponseData
                {
                    Code = "400",
                    Message = "Failed",
                    Data = ex.Message
                }));
            }
        }
 public ActionResult GetOrdersOfUser(string username)
 {
     try
     {
         var orders = GH.GetOrders(username, order_db);
         if (orders != null)
         {
             return(Ok(new ResponseData
             {
                 Code = "200",
                 Message = "Success",
                 Data = orders
             }));
         }
         else
         {
             return(BadRequest(new ResponseData
             {
                 Code = "404",
                 Message = "No orders found",
                 Data = null
             }));
         }
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("OrderController", "GetOrdersOfUser", "GetOrdersOfUser", ex.Message);
         return(BadRequest(new ResponseData
         {
             Code = "400",
             Message = "Failed",
             Data = ex.Message
         }));
     }
 }
Ejemplo n.º 4
0
 /// <summary>Create email body to send gift through email</summary>
 /// <param name="value"></param>
 /// <param name="couponCode"></param>
 /// <param name="message"></param>
 /// <param name="fullName"></param>
 /// <param name="objectName"></param>
 public static string CreateEmailBody_SendGiftCard(string value, string couponCode, string message, string fullName, string objectName)
 {
     try
     {
         string emailBody;
         var    dir  = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
         var    path = Path.Combine(dir, "EmailTemplate/ECard.html");
         using (StreamReader reader = File.OpenText(path))
         {
             emailBody = reader.ReadToEnd();
         }
         List <string> matchedString = GlobalHelper.StringBetweenTwoCharacters(objectName, "All-Gifts-", "-NA-");
         var           replaceName   = "You have received an e-gift from " + fullName;
         var           imageUrl      = "https://s3.ap-south-1.amazonaws.com/acemailtemplate/Gift-Banner-" + matchedString[0] + ".jpg";
         var           replaceImage  = "<img src=" + imageUrl + " width='600' height='124'>";
         var           replacedValue = "Value of gift is &#8377;" + value;
         emailBody = emailBody.Replace("{GiftValue}", replacedValue);
         emailBody = emailBody.Replace("{CouponCode}", couponCode);
         emailBody = emailBody.Replace("{Message}", message);
         emailBody = emailBody.Replace("{FullName}", replaceName);
         emailBody = emailBody.Replace("{Image}", replaceImage);
         return(emailBody);
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("EmailHelper", "CreateEmailBody_SendGiftCard", ex.Message);
         return("Failed");
     }
 }
        /// <summary>To record invalid login attempts</summary>
        /// <param name="filter"></param>
        public static string RecordLoginAttempts(FilterDefinition <BsonDocument> filter)
        {
            try
            {
                var verifyUser = BsonSerializer.Deserialize <RegisterModel>(MH.GetSingleObject(filter, "Authentication", "Authentication").Result);
                if (verifyUser.WrongAttemptCount < 10)
                {
                    var update = Builders <BsonDocument> .Update.Set("WrongAttemptCount", verifyUser.WrongAttemptCount + 1);

                    var result = MH.UpdateSingleObject(filter, "Authentication", "Authentication", update).Result;
                    return("Login Attempt Recorded");
                }
                else
                {
                    var update = Builders <BsonDocument> .Update.Set("Status", "Revoked");

                    var result = MH.UpdateSingleObject(filter, "Authentication", "Authentication", update).Result;
                    return("Account Blocked");
                }
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("MongoHelper", "RecordLoginAttempts", ex.Message);
                return("Failed");
            }
        }
Ejemplo n.º 6
0
        /// <summary>Update order details</summary>
        /// <param name="orderId"></param>
        public async static Task <string> UpdatePaymentDetails(long orderId)
        {
            try
            {
                PaymentMethod     paymentDetails = new PaymentMethod();
                List <StatusCode> statusCodeList = new List <StatusCode>();
                var orderData = BsonSerializer.Deserialize <OrderInfo>(MH.GetSingleObject(Builders <BsonDocument> .Filter.Eq("OrderId", orderId), "OrderDB", "OrderInfo").Result);
                foreach (var detail in orderData.PaymentDetails.Status)
                {
                    statusCodeList.Add(detail);
                }
                statusCodeList.Add(new StatusCode {
                    StatusId = 2, Description = "Payment Received", Date = DateTime.UtcNow
                });
                paymentDetails.Status = statusCodeList;
                var updatePaymentDetails = await MH.UpdateSingleObject(Builders <BsonDocument> .Filter.Eq("OrderId", orderId), "OrderDB", "OrderInfo", Builders <BsonDocument> .Update.Set("PaymentDetails", paymentDetails));

                return("Success");
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("MongoHelper", "UpdatePaymentDetails", ex.Message);
                return(null);
            }
        }
 /// <summary>Prepare post form for paymet through PayUMoney</summary>
 /// <param name="url"></param>
 /// <param name="data"></param>
 public static string PreparePOSTForm(string url, Hashtable data)
 {
     try
     {
         string        formID  = "PostForm";
         StringBuilder strForm = new StringBuilder();
         strForm.Append("<form id=\"" + formID + "\" name=\"" + formID + "\" action=\"" + url + "\" method=\"POST\">");
         foreach (DictionaryEntry key in data)
         {
             strForm.Append("<input type=\"hidden\" name=\"" + key.Key + "\" value=\"" + key.Value + "\">");
         }
         strForm.Append("</form>");
         StringBuilder strScript = new StringBuilder();
         strScript.Append("<script language='javascript'>");
         strScript.Append("var v" + formID + " = document." + formID + ";");
         strScript.Append("v" + formID + ".submit();");
         strScript.Append("</script>");
         strForm.Append(strScript);
         return(strForm.ToString());
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("PayUHelper", "PreparePOSTForm", ex.Message);
         return(null);
     }
 }
Ejemplo n.º 8
0
 /// <summary>Send email to user who subscribes for news letter service</summary>
 /// <param name="emailReceiver"></param>
 public static async Task <string> SendEmail_NewsLetterService(string emailReceiver)
 {
     try
     {
         string emailSender = GlobalHelper.ReadXML().Elements("email").Where(x => x.Element("current").Value.Equals("Yes")).Descendants("emailsender").First().Value;
         using (var client = new AmazonSimpleEmailServiceClient(GetCredentials("accesskey"), GetCredentials("secretkey"), Amazon.RegionEndpoint.USWest2))
         {
             var sendRequest = new SendEmailRequest
             {
                 Source      = emailSender,
                 Destination = new Destination {
                     ToAddresses = new List <string> {
                         emailReceiver
                     }
                 },
                 Message = new Message
                 {
                     Subject = new Content(GlobalHelper.ReadXML().Elements("email").Where(x => x.Element("current").Value.Equals("Yes")).Descendants("emailsubject5").First().Value),
                     Body    = new Body
                     {
                         Html = new Content(CreateEmailBody_NewsLetterService())
                     }
                 }
             };
             var responce = await client.SendEmailAsync(sendRequest);
         }
         return("Success");
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("EmailHelper", "SendEmail_NewsLetterService", ex.Message);
         return("Failed");
     }
 }
 public ActionResult GetOrderById(int orderid)
 {
     try
     {
         var checkData = MH.CheckForDatas("OrderId", orderid, null, null, "OrderDB", "OrderInfo");
         if (checkData != null)
         {
             return(Ok(new ResponseData
             {
                 Code = "200",
                 Message = "Success",
                 Data = BsonSerializer.Deserialize <OrderInfo>(checkData)
             }));
         }
         else
         {
             return(BadRequest(new ResponseData
             {
                 Code = "404",
                 Message = "No orders found",
                 Data = null
             }));
         }
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("OrderController", "GetOrdersOfUser", ex.Message);
         return(BadRequest(new ResponseData
         {
             Code = "400",
             Message = "Failed",
             Data = ex.Message
         }));
     }
 }
Ejemplo n.º 10
0
        /// <summary></summary>
        /// <param name="objectId"></param>
        /// <param name="updateData"></param>
        /// <param name="updateField"></param>
        /// <param name="objectName"></param>
        public async static Task <bool?> UpdateProductDetails(dynamic objectId, dynamic updateData, string updateField, string objectName)
        {
            try
            {
                var update = await MH.UpdateSingleObject(Builders <BsonDocument> .Filter.Eq("_id", objectId), "ProductDB", "Product", Builders <BsonDocument> .Update.Set(updateField, updateData));

                string MinioObject_URL;
                //MinioObject_URL = WH.GetMinioObject("arthurclive-products", objectName).Result;
                //MinioObject_URL = AH.GetAmazonS3Object("arthurclive-products", objectName);
                MinioObject_URL = AH.GetS3Object("arthurclive-products", objectName);
                var update1 = await MH.UpdateSingleObject(Builders <BsonDocument> .Filter.Eq("_id", objectId), "ProductDB", "Product", Builders <BsonDocument> .Update.Set("ProductSKU", objectName));

                var update2 = await MH.UpdateSingleObject(Builders <BsonDocument> .Filter.Eq("_id", objectId), "ProductDB", "Product", Builders <BsonDocument> .Update.Set("MinioObject_URL", MinioObject_URL));

                if (update1 == true & update2 == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("MongoHelper", "UpdateProductDetails", ex.Message);
                return(null);
            }
        }
        public async Task <ActionResult> GetDefaultAddressOfUser(string username)
        {
            try
            {
                var userCollection = _db.GetCollection <Address>("UserInfo");
                var filter         = Builders <Address> .Filter.Eq("UserName", username) & Builders <Address> .Filter.Eq("DefaultAddress", true);

                IAsyncCursor <Address> cursor = await userCollection.FindAsync(filter);

                var userInfo = cursor.ToList();
                return(Ok(new ResponseData
                {
                    Code = "200",
                    Message = "Success",
                    Data = userInfo
                }));
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("UserController", "GetDefaultAddressOfUser", "GetDefaultAddressOfUser", ex.Message);
                return(BadRequest(new ResponseData
                {
                    Code = "400",
                    Message = "Failed",
                    Data = ex.Message
                }));;
            }
        }
        public async Task <ActionResult> Post([FromBody] Product product)
        {
            try
            {
                product.ProductDiscountPrice = (product.ProductPrice - (product.ProductPrice * (product.ProductDiscount / 100)));
                product.ProductSKU           = product.ProductFor + "-" + product.ProductType + "-" + product.ProductDesign + "-" + product.ProductColour + "-" + product.ProductSize;
                string objectName = product.ProductSKU + ".jpg";
                //product.MinioObject_URL = WH.GetMinioObject("arthurclive-products", objectName).Result;
                //product.MinioObject_URL = AH.GetAmazonS3Object("arthurclive-products", objectName);
                product.MinioObject_URL = AH.GetS3Object("arthurclive-products", objectName);
                var collection = _db.GetCollection <Product>("Product");
                await collection.InsertOneAsync(product);

                return(Ok(new ResponseData
                {
                    Code = "200",
                    Message = "Inserted",
                    Data = null
                }));
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("ProductController", "Post", "Post", ex.Message);
                return(BadRequest(new ResponseData
                {
                    Code = "400",
                    Message = "Failed",
                    Data = ex.Message
                }));
            }
        }
        public async Task <ActionResult> GetProductsInWishList(string username)
        {
            try
            {
                var collection = _db.GetCollection <WishList>("WishList");
                var filter     = Builders <WishList> .Filter.Eq("UserName", username);

                IAsyncCursor <WishList> cursor = await collection.FindAsync(filter);

                var products = cursor.ToList();
                foreach (var data in products)
                {
                    string objectName = data.ProductSKU + ".jpg";
                    //data.ObjectUrl = WH.GetMinioObject("products", objectName).Result;
                    //data.ObjectUrl = AH.GetAmazonS3Object("arthurclive-products", objectName);
                    data.MinioObject_URL = AH.GetS3Object("arthurclive-products", objectName);
                }
                return(Ok(new ResponseData
                {
                    Code = "200",
                    Message = "Success",
                    Data = products
                }));
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("AuthController", "GetProductsInWishList", "GetProductsInWishList", ex.Message);
                return(BadRequest(new ResponseData
                {
                    Code = "400",
                    Message = "Failed",
                    Data = ex.Message
                }));
            }
        }
        public async Task <ActionResult> RefreshUserInfo([FromBody] AddressList data, string username)
        {
            try
            {
                var addressFilter = Builders <Address> .Filter.Eq("UserName", username);

                var addressCollection = _db.GetCollection <Address>("UserInfo");
                var result            = addressCollection.DeleteManyAsync(addressFilter).Result;
                if (data.ListOfAddress.Count > 0)
                {
                    data.ListOfAddress.ToList().ForEach(c => c.UserName = username);
                    var authCollection = _db.GetCollection <Address>("UserInfo");
                    await authCollection.InsertManyAsync(data.ListOfAddress);
                }
                return(Ok(new ResponseData
                {
                    Code = "200",
                    Message = "Inserted",
                    Data = null
                }));
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("UserController", "RefreshUserInfo", "RefreshUserInfo", ex.Message);
                return(BadRequest(new ResponseData
                {
                    Code = "400",
                    Message = "Failed",
                    Data = ex.Message
                }));
            }
        }
Ejemplo n.º 15
0
 /// <summary>Get string between to characters</summary>
 /// <param name="text"></param>
 /// <param name="startString"></param>
 /// <param name="endString"></param>
 public static List <string> StringBetweenTwoCharacters(string text, string startString, string endString)
 {
     try
     {
         List <string> matched = new List <string>();
         int           indexStart = 0, indexEnd = 0;
         bool          exit = false;
         while (!exit)
         {
             indexStart = text.IndexOf(startString);
             indexEnd   = text.IndexOf(endString);
             if (indexStart != -1 && indexEnd != -1)
             {
                 matched.Add(text.Substring(indexStart + startString.Length,
                                            indexEnd - indexStart - startString.Length));
                 text = text.Substring(indexEnd + endString.Length);
             }
             else
             {
                 exit = true;
             }
         }
         return(matched);
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("GlobalHelper", "StringBetweenTwoCharacters", ex.Message);
         return(null);
     }
 }
Ejemplo n.º 16
0
        /// <summary>Remove product in a particular cart</summary>
        /// <param name="orderId"></param>
        /// <param name="userName"></param>
        /// <param name="email"></param>
        public async static Task <string> RemoveCartItems(long orderId, string userName, string email)
        {
            try
            {
                IAsyncCursor <Cart> cartCursor = await _client.GetDatabase("UserInfo").GetCollection <Cart>("Cart").FindAsync(Builders <Cart> .Filter.Eq("UserName", userName));

                var cartDatas = cartCursor.ToList();
                foreach (var cart in cartDatas)
                {
                    foreach (var product in GetProducts(cart.ProductSKU, _client.GetDatabase("ProductDB")).Result)
                    {
                        long updateQuantity = product.ProductStock - cart.ProductQuantity;
                        if (product.ProductStock - cart.ProductQuantity < 0)
                        {
                            updateQuantity = 0;
                            var emailResponce = EmailHelper.SendEmailToAdmin(userName.ToString(), email.ToString(), cart.ProductSKU, cart.ProductQuantity, product.ProductStock, orderId).Result;
                        }
                        var result = MH.UpdateSingleObject(Builders <BsonDocument> .Filter.Eq("ProductSKU", cart.ProductSKU), "ProductDB", "Product", Builders <BsonDocument> .Update.Set("ProductStock", updateQuantity)).Result;
                    }
                }
                var removeCartItems = _client.GetDatabase("UserInfo").GetCollection <Cart>("Cart").DeleteMany(Builders <Cart> .Filter.Eq("UserName", userName));
                return("Success");
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("MongoHelper", "RemoveCartItems", ex.Message);
                return(null);
            }
        }
        /// <summary>Get list of objects from MongoDB</summary>
        /// <param name="filterField1"></param>
        /// <param name="filterField2"></param>
        /// <param name="filterField3"></param>
        /// <param name="filterData1"></param>
        /// <param name="filterData2"></param>
        /// <param name="filterData3"></param>
        /// <param name="dbName"></param>
        /// <param name="collectionName"></param>
        public static async Task <List <BsonDocument> > GetListOfObjects(string filterField1, dynamic filterData1, string filterField2, dynamic filterData2, string filterField3, dynamic filterData3, string dbName, string collectionName)
        {
            try
            {
                _mongodb = MH._client.GetDatabase(dbName);
                var collection = _mongodb.GetCollection <BsonDocument>(collectionName);
                if (filterField1 == null & filterField2 == null & filterField3 == null)
                {
                    filter = FilterDefinition <BsonDocument> .Empty;
                }
                else if (filterField1 != null & filterField2 == null & filterField3 == null)
                {
                    filter = Builders <BsonDocument> .Filter.Eq(filterField1, filterData1);
                }
                else if (filterField1 != null & filterField2 != null & filterField3 == null)
                {
                    filter = Builders <BsonDocument> .Filter.Eq(filterField1, filterData1) & Builders <BsonDocument> .Filter.Eq(filterField2, filterData2);
                }
                else if (filterField1 != null & filterField2 != null & filterField3 != null)
                {
                    filter = Builders <BsonDocument> .Filter.Eq(filterField1, filterData1) & Builders <BsonDocument> .Filter.Eq(filterField2, filterData2) & Builders <BsonDocument> .Filter.Eq(filterField3, filterData3);
                }
                IAsyncCursor <BsonDocument> cursor = await collection.FindAsync(filter);

                return(cursor.ToList());
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("MongoHelper", "GetListOfObjects", ex.Message);
                return(null);
            }
        }
        /// <summary>Upload image to s3</summary>
        /// <param name="file">Details of image</param>
        /// <param name="bucketName">Details of image</param>
        /// <param name="objectName">Details of image</param>
        public async static Task <bool> UploadImageToS3(IFormFile file, string bucketName, string objectName)
        {
            try
            {
                IAmazonS3 client;
                using (client = GetAmazonS3Client())
                {
                    var request = new PutObjectRequest()
                    {
                        BucketName  = bucketName,
                        CannedACL   = S3CannedACL.PublicRead,
                        Key         = string.Format(objectName),
                        InputStream = file.OpenReadStream()
                    };

                    await client.PutObjectAsync(request);
                }
                return(true);
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("AmazonHelper", "UploadImageToS3", ex.Message);
                return(false);
            }
        }
Ejemplo n.º 19
0
        public async Task <ActionResult> ForgotPassword([FromBody] ForgotPasswordModel data)
        {
            try
            {
                string OTP;
                var    checkUser = MH.CheckForDatas("UserName", data.UserName, null, null, "Authentication", "Authentication");
                var    filter    = Builders <BsonDocument> .Filter.Eq("UserName", data.UserName);

                var user = MH.GetSingleObject(filter, "Authentication", "Authentication").Result;
                if (user != null)
                {
                    var userData = BsonSerializer.Deserialize <RegisterModel>(user);
                    VerificationModel smsModel = new VerificationModel();
                    smsModel.UserName = data.UserName;
                    if (data.UserLocation == "IN")
                    {
                        Random codeGenerator = new Random();
                        OTP = codeGenerator.Next(0, 1000000).ToString("D6");
                        smsModel.VerificationCode = OTP;
                        SMSHelper.SendSMS(data.UserName, OTP);
                    }
                    else
                    {
                        OTP = Guid.NewGuid().ToString();
                        string link = GlobalHelper.GetIpConfig() + data.UserName + "/" + OTP + "/yes";
                        await EmailHelper.SendEmail(userData.FullName, data.UserName, link);
                    }
                    var update = Builders <BsonDocument> .Update.Set("Status", "Not Verified").Set("OTPExp", DateTime.UtcNow.AddMinutes(2))
                                 .Set("VerificationCode", smsHasher.HashPassword(smsModel, OTP));

                    var result = MH.UpdateSingleObject(filter, "Authentication", "Authentication", update).Result;
                    return(Ok(new ResponseData
                    {
                        Code = "200",
                        Message = "Success",
                        Data = null
                    }));
                }
                else
                {
                    return(BadRequest(new ResponseData
                    {
                        Code = "404",
                        Message = "User not found",
                        Data = null
                    }));
                }
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("AuthController", "ForgetPassword", "ForgetPassword", ex.Message);
                return(BadRequest(new ResponseData
                {
                    Code = "400",
                    Message = "Failed",
                    Data = null
                }));
            }
        }
Ejemplo n.º 20
0
 public ActionResult MakePayment([FromBody] PaymentModel model)
 {
     try
     {
         string    SuccessUrl = "http://localhost:5001/api/payment/success";
         string    FailureUrl = "http://localhost:5001/api/payment/failed";
         string    txnId      = PU.GetTxnId();
         string    hashString = PU.GetHashString(txnId, model);
         string    hash       = PU.Generatehash512(hashString).ToLower();
         string    action     = GlobalHelper.ReadXML().Elements("payu").Where(x => x.Element("current").Value.Equals("Yes")).Descendants("url").First().Value + "/_payment";
         Hashtable data       = new Hashtable();
         data.Add("hash", hash);
         data.Add("txnid", txnId);
         data.Add("key", "gtKFFx");
         string AmountForm = Convert.ToDecimal(model.Amount).ToString("g29");
         data.Add("amount", AmountForm);
         data.Add("firstname", model.FirstName);
         data.Add("email", model.Email);
         data.Add("phone", model.PhoneNumber);
         data.Add("productinfo", model.ProductInfo);
         data.Add("surl", SuccessUrl);
         data.Add("furl", FailureUrl);
         data.Add("lastname", model.LastName);
         data.Add("curl", "");
         data.Add("address1", model.AddressLine1);
         data.Add("address2", model.AddressLine2);
         data.Add("city", model.City);
         data.Add("state", model.State);
         data.Add("country", model.Country);
         data.Add("zipcode", model.ZipCode);
         data.Add("udf1", "");
         data.Add("udf2", "");
         data.Add("udf3", "");
         data.Add("udf4", "");
         data.Add("udf5", "");
         data.Add("pg", "");
         data.Add("service_provider", "PayUMoney");
         StringBuilder strForm  = PU.PreparePOSTForm(action, data);
         var           form     = PU.PreparePOSTForm(action, data);
         dynamic       UserInfo = new System.Dynamic.ExpandoObject();
         UserInfo.form = form;
         return(Ok(new ResponseData
         {
             Code = "200",
             Content = UserInfo,
             Data = null
         }));
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("PaymentController", "MakePayment", "MakePayment", ex.Message);
         return(BadRequest(new ResponseData
         {
             Code = "400",
             Message = "Failed",
             Data = null
         }));
     }
 }
        public ActionResult UpdateCoupon([FromBody] UpdateCoupon data, string code)
        {
            try
            {
                var checkData = MH.CheckForDatas("Code", code, null, null, "CouponDB", "Coupon");
                if (checkData != null)
                {
                    var result = BsonSerializer.Deserialize <Coupon>(checkData);
                    var filter = Builders <BsonDocument> .Filter.Eq("Code", code);

                    if (data.ApplicableFor != null)
                    {
                        var update = MH.UpdateSingleObject(filter, "CouponDB", "Coupon", Builders <BsonDocument> .Update.Set("ApplicableFor", data.ApplicableFor));
                    }
                    if (data.ExpiryTime != null)
                    {
                        var update = MH.UpdateSingleObject(filter, "CouponDB", "Coupon", Builders <BsonDocument> .Update.Set("ExpiryTime", data.ExpiryTime));
                    }
                    if (data.Value > 0)
                    {
                        var update = MH.UpdateSingleObject(filter, "CouponDB", "Coupon", Builders <BsonDocument> .Update.Set("Value", data.Value));
                    }
                    if (data.Percentage != null)
                    {
                        var updateResult = MH.UpdateSingleObject(filter, "CouponDB", "Coupon", Builders <BsonDocument> .Update.Set("Percentage", data.Percentage));
                    }
                    if (data.UsageCount > 0)
                    {
                        var update = MH.UpdateSingleObject(filter, "CouponDB", "Coupon", Builders <BsonDocument> .Update.Set("UsageCount", data.UsageCount));
                    }
                    return(Ok(new ResponseData
                    {
                        Code = "200",
                        Message = "Coupon updated successfully",
                        Data = null
                    }));
                }
                else
                {
                    return(BadRequest(new ResponseData
                    {
                        Code = "404",
                        Message = "Coupon not found",
                        Data = null
                    }));
                }
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("CouponController", "UpdateCoupon", ex.Message);
                return(BadRequest(new ResponseData
                {
                    Code = "400",
                    Message = "Failed",
                    Data = ex.Message
                }));
            }
        }
Ejemplo n.º 22
0
 /// <summary>Create email body to send email to user who subscribes for news letter service</summary>
 /// <param name="orderInfo"></param>
 /// <param name="productSKU"></param>
 /// <param name="billingAddress"></param>
 /// <param name="deliveryAddress"></param>
 /// <param name="productDetails"></param>
 public static string CreateEmailBody_ProductDetails(OrderInfo orderInfo, string productSKU, Address billingAddress, Address deliveryAddress, ProductDetails productDetails)
 {
     try
     {
         string emailBody;
         var    dir  = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
         var    path = Path.Combine(dir, "EmailTemplate/OrderDetails.html");
         using (StreamReader reader = File.OpenText(path))
         {
             emailBody = reader.ReadToEnd();
         }
         var imageUrl     = "https://s3.ap-south-1.amazonaws.com/arthurclive-products/" + productSKU + ".jpg";
         var replaceImage = "<img src=" + imageUrl + " width='250' height='300'>";
         var colourCircle = "<span style=\"border-radius:50%; border-style:double; padding:20px; background-color:" + productDetails.ProductInCart.ProductColour + "; display:block; width:20px; height:20px\">";
         var replaceSize  = "";
         if (productDetails.ProductInCart.ProductSize.Contains("_"))
         {
             replaceSize = productDetails.ProductInCart.ProductSize.Replace("_", "-");
         }
         else
         {
             replaceSize = productDetails.ProductInCart.ProductSize;
         }
         emailBody = emailBody.Replace("{BA_AddressLines}", billingAddress.AddressLines);
         emailBody = emailBody.Replace("{BA_City}", billingAddress.City);
         emailBody = emailBody.Replace("{BA_State}", billingAddress.State);
         emailBody = emailBody.Replace("{BA_PinCode}", billingAddress.PinCode);
         emailBody = emailBody.Replace("{BA_Country}", billingAddress.Country);
         emailBody = emailBody.Replace("{DA_AddressLines}", deliveryAddress.AddressLines);
         emailBody = emailBody.Replace("{DA_City}", deliveryAddress.City);
         emailBody = emailBody.Replace("{DA_State}", deliveryAddress.State);
         emailBody = emailBody.Replace("{DA_PinCode}", deliveryAddress.PinCode);
         emailBody = emailBody.Replace("{DA_Country}", deliveryAddress.Country);
         emailBody = emailBody.Replace("{Invoice Number}", orderInfo.OrderId.ToString());
         emailBody = emailBody.Replace("{Order Number}", "ACODR-" + orderInfo.OrderId.ToString());
         emailBody = emailBody.Replace("{Order Date}", productDetails.StatusCode[0].Date.Date.ToString());
         emailBody = emailBody.Replace("{Payment Method}", orderInfo.PaymentMethod);
         emailBody = emailBody.Replace("{Image}", replaceImage);
         emailBody = emailBody.Replace("{P_For}", productDetails.ProductInCart.ProductFor);
         emailBody = emailBody.Replace("{P_Type}", productDetails.ProductInCart.ProductType);
         emailBody = emailBody.Replace("{P_Tshirt}", productDetails.ProductInCart.ProductDesign);
         emailBody = emailBody.Replace("{Colour_Image}", colourCircle);
         emailBody = emailBody.Replace("{P_Size}", replaceSize);
         emailBody = emailBody.Replace("{Quantity}", productDetails.ProductInCart.ProductQuantity.ToString());
         emailBody = emailBody.Replace("{UnitPrice}", productDetails.ProductInCart.ProductDiscountPrice.ToString());
         emailBody = emailBody.Replace("{ItemTotal}", (productDetails.ProductInCart.ProductDiscountPrice * productDetails.ProductInCart.ProductQuantity).ToString());
         emailBody = emailBody.Replace("{Tax}", (((productDetails.ProductInCart.ProductPrice * productDetails.ProductInCart.ProductQuantity * 5) / 100)).ToString());
         emailBody = emailBody.Replace("{Discount}", productDetails.ProductInCart.ProductDiscount.ToString());
         emailBody = emailBody.Replace("{GrandTotal}", ((productDetails.ProductInCart.ProductPrice * productDetails.ProductInCart.ProductQuantity) + (((productDetails.ProductInCart.ProductPrice * productDetails.ProductInCart.ProductQuantity * 5) / 100))).ToString());
         return(emailBody);
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("EmailHelper", "CreateEmailBody_ProductDetails", ex.Message);
         return("Failed");
     }
 }
Ejemplo n.º 23
0
        public ActionResult ChangePassword([FromBody] LoginModel data)
        {
            try
            {
                var filter = Builders <BsonDocument> .Filter.Eq("UserName", data.UserName);

                var user = MH.GetSingleObject(filter, "Authentication", "Authentication").Result;
                if (user != null)
                {
                    var verifyUser = BsonSerializer.Deserialize <RegisterModel>(user);
                    if (verifyUser.Status == "Verified")
                    {
                        RegisterModel registerModel = new RegisterModel {
                            UserName = data.UserName, Password = data.Password
                        };
                        var update = Builders <BsonDocument> .Update.Set("Password", passwordHasher.HashPassword(registerModel, data.Password));

                        var result = MH.UpdateSingleObject(filter, "Authentication", "Authentication", update).Result;
                        return(Ok(new ResponseData
                        {
                            Code = "200",
                            Message = "Password Changed Successfully",
                            Data = null
                        }));
                    }
                    else
                    {
                        return(BadRequest(new ResponseData
                        {
                            Code = "401",
                            Message = "User Not Verified to Change Password",
                            Data = null
                        }));
                    }
                }
                else
                {
                    return(BadRequest(new ResponseData
                    {
                        Code = "404",
                        Message = "User Not Found",
                        Data = null
                    }));
                }
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("AuthController", "ChangePassword", "ChangePassword", ex.Message);
                return(BadRequest(new ResponseData
                {
                    Code = "400",
                    Message = "Failed",
                    Data = null
                }));
            }
        }
Ejemplo n.º 24
0
        public ActionResult DeactivateAccount([FromBody] LoginModel data)
        {
            try
            {
                var filter = Builders <BsonDocument> .Filter.Eq("PhoneNumber", data.UserName);

                var user = MH.GetSingleObject(filter, "Authentication", "Authentication").Result;
                if (user != null)
                {
                    var           verifyUser    = BsonSerializer.Deserialize <RegisterModel>(user);
                    RegisterModel registerModel = new RegisterModel {
                        UserName = data.UserName, Password = data.Password
                    };
                    if (passwordHasher.VerifyHashedPassword(registerModel, verifyUser.Password, data.Password).ToString() == "Success")
                    {
                        var authCollection = _db.GetCollection <RegisterModel>("Authentication");
                        var response       = authCollection.DeleteOneAsync(user);
                        return(Ok(new ResponseData
                        {
                            Code = "200",
                            Message = "User Deactivated",
                            Data = null
                        }));
                    }
                    else
                    {
                        return(BadRequest(new ResponseData
                        {
                            Code = "401",
                            Message = "Invalid UserName or Password",
                            Data = null
                        }));
                    }
                }
                else
                {
                    return(BadRequest(new ResponseData
                    {
                        Code = "404",
                        Message = "User Not Found",
                        Data = null
                    }));
                }
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("AuthController", "DeactivateAccount", "DeactivateAccount", ex.Message);
                return(BadRequest(new ResponseData
                {
                    Code = "400",
                    Message = "Failed",
                    Data = null
                }));
            }
        }
        public async Task <ActionResult> UpdateCategory([FromBody] Category data, string productFor, string productType)
        {
            try
            {
                var checkData = MH.CheckForDatas("ProductFor", productFor, "ProductType", productType, "ProductDB", "Category");
                if (checkData != null)
                {
                    var objectId = BsonSerializer.Deserialize <Category>(checkData).Id;
                    var filter   = Builders <BsonDocument> .Filter.Eq("_id", objectId);

                    if (data.ProductFor != null)
                    {
                        var value      = BsonSerializer.Deserialize <Category>(MH.CheckForDatas("_id", objectId, null, null, "ProductDB", "Category")).ProductType;
                        var objectName = data.ProductFor + "-" + value;
                        GH.UpdateCategoryDetails(BsonSerializer.Deserialize <Category>(checkData).Id, productFor, productType, data.ProductFor, "ProductFor", objectName);
                    }
                    if (data.ProductType != null)
                    {
                        var value      = BsonSerializer.Deserialize <Category>(MH.CheckForDatas("_id", objectId, null, null, "ProductDB", "Category")).ProductFor;
                        var objectName = value + "-" + data.ProductType;
                        GH.UpdateCategoryDetails(BsonSerializer.Deserialize <Category>(checkData).Id, productFor, productType, data.ProductType, "ProductType", objectName);
                    }
                    if (data.Description != null)
                    {
                        var update = await MH.UpdateSingleObject(filter, "ProductDB", "Category", Builders <BsonDocument> .Update.Set("Description", data.Description));
                    }
                    return(Ok(new ResponseData
                    {
                        Code = "200",
                        Message = "Updated",
                        Data = null
                    }));
                }
                else
                {
                    return(BadRequest(new ResponseData
                    {
                        Code = "404",
                        Message = "Category not found",
                        Data = null
                    }));
                }
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("CategoryController", "UpdateCategory", "UpdateCategory", ex.Message);
                return(BadRequest(new ResponseData
                {
                    Code = "400",
                    Message = "Failed",
                    Data = ex.Message
                }));
            }
        }
Ejemplo n.º 26
0
        public async Task <ActionResult> Subscribe(string emailid)
        {
            try
            {
                if (emailid != null)
                {
                    var checkUser = MH.CheckForDatas("Email", emailid, null, null, "SubscribeDB", "SubscribedUsers");
                    if (checkUser == null)
                    {
                        await _db.GetCollection <Subscribe>("SubscribedUsers").InsertOneAsync(new Subscribe {
                            Email = emailid
                        });

                        var sendEmail = EmailHelper.SendEmail_NewsLetterService(emailid);
                        return(Ok(new ResponseData
                        {
                            Code = "200",
                            Message = "Subscribed Succesfully",
                            Data = null
                        }));
                    }
                    else
                    {
                        return(BadRequest(new ResponseData
                        {
                            Code = "401",
                            Message = "User Already Subscribed",
                            Data = null
                        }));
                    }
                }
                else
                {
                    return(BadRequest(new ResponseData
                    {
                        Code = "402",
                        Message = "EmailId connot be empty",
                        Data = null
                    }));
                }
            }
            catch (Exception ex)
            {
                LoggerDataAccess.CreateLog("AdminContoller", "Subscribe", ex.Message);
                return(BadRequest(new ResponseData
                {
                    Code = "400",
                    Message = "Failed",
                    Data = ex.Message
                }));
            }
        }
Ejemplo n.º 27
0
 /// <summary>Get ip config from xml</summary>
 public static string GetIpConfig()
 {
     try
     {
         var result = ReadXML().Elements("ipconfig").Where(x => x.Element("current").Value.Equals("Yes")).Descendants("authorizedserver2");
         return(result.First().Value);
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("GlobalHelper", "GetIpConfig", ex.Message);
         return(null);
     }
 }
Ejemplo n.º 28
0
 /// <summary>Get amazon SES credentials from xml file</summary>
 /// <param name="key"></param>
 public static string GetCredentials(string key)
 {
     try
     {
         var result = GlobalHelper.ReadXML().Elements("amazonses").Where(x => x.Element("current").Value.Equals("Yes")).Descendants(key);
         return(result.First().Value);
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("EmailHelper", "GetCredentials", ex.Message);
         return(ex.Message);
     }
 }
Ejemplo n.º 29
0
 /// <summary>Send email to user who subscribes for news letter service</summary>
 /// <param name="emailReceiver"></param>
 /// <param name="orderId"></param>
 public static async Task <string> SendEmail_ProductDetails(string emailReceiver, long orderId)
 {
     try
     {
         string emailSender = GlobalHelper.ReadXML().Elements("email").Where(x => x.Element("current").Value.Equals("Yes")).Descendants("emailsender").First().Value;
         var    orderInfo   = BsonSerializer.Deserialize <OrderInfo>(MongoHelper.CheckForDatas("OrderId", orderId, null, null, "OrderDB", "OrderInfo"));
         foreach (var product in orderInfo.ProductDetails)
         {
             Address billingAddress  = new Address();
             Address deliveryAddress = new Address();
             foreach (var address in orderInfo.Address)
             {
                 if (address.BillingAddress == true)
                 {
                     billingAddress = address;
                 }
                 if (address.ShippingAddress == true)
                 {
                     deliveryAddress = address;
                 }
             }
             using (var client = new AmazonSimpleEmailServiceClient(GetCredentials("accesskey"), GetCredentials("secretkey"), Amazon.RegionEndpoint.USWest2))
             {
                 var sendRequest = new SendEmailRequest
                 {
                     Source      = emailSender,
                     Destination = new Destination {
                         ToAddresses = new List <string> {
                             emailReceiver
                         }
                     },
                     Message = new Message
                     {
                         Subject = new Content(GlobalHelper.ReadXML().Elements("email").Where(x => x.Element("current").Value.Equals("Yes")).Descendants("emailsubject6").First().Value),
                         Body    = new Body
                         {
                             Html = new Content(CreateEmailBody_ProductDetails(orderInfo, product.ProductSKU, billingAddress, deliveryAddress, product))
                         }
                     }
                 };
                 var responce = await client.SendEmailAsync(sendRequest);
             }
         }
         return("Success");
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("EmailHelper", "SendEmail_ProductDetails", ex.Message);
         return("Failed");
     }
 }
Ejemplo n.º 30
0
 /// <summary>xml file</summary>
 public static XElement ReadXML()
 {
     try
     {
         var dir    = GetCurrentDir();
         var xmlStr = File.ReadAllText(Path.Combine(dir, "AmazonKeys.xml"));
         return(XElement.Parse(xmlStr));
     }
     catch (Exception ex)
     {
         LoggerDataAccess.CreateLog("GlobalHelper", "ReadXML", ex.Message);
         return(null);
     }
 }