示例#1
0
        public IActionResult deactivateCustomer(int Id)
        {
            var obj = new User();

            try
            {
                if (Id > 0)
                {
                    obj = db.Users.Where(x => x.Id == Id).FirstOrDefault();
                    if (obj.IsActive == false)
                    {
                        obj.IsActive = true;
                    }
                    else
                    {
                        obj.IsActive = false;
                    }

                    db.SaveChanges();
                }
            }
            catch (Exception E)
            {
                Console.Write(E.Message);
            }
            return(Ok());
        }
示例#2
0
        public IActionResult Save(SearchTerm model)
        {
            model.IsActive  = true;
            model.IsDisplay = false;
            var data = db.SearchTerm.Where(x => x.Name == model.Name && x.IsActive == true).FirstOrDefault();

            if (data == null)
            {
                db.SearchTerm.Add(model);
            }
            else
            {
                data.UserCount    = data.UserCount + 1;
                data.ProductCount = model.ProductCount;
            }
            try
            {
                db.SaveChanges();
                return(Ok());
            }
            catch (Exception ex)
            {
                return(Ok(ex));
            }
        }
        public IActionResult transaction([FromBody] Models.PaymentTransaction paymentTransaction)
        {
            PaymentTransaction model = new PaymentTransaction();

            try
            {
                if (paymentTransaction != null)
                {
                    model.intent     = paymentTransaction.intent;
                    model.FeesAmount = paymentTransaction.FeesAmount;
                    model.orderID    = paymentTransaction.orderID;
                    model.payerID    = paymentTransaction.payerID;
                    model.paymentID  = paymentTransaction.paymentID;
                    //model.PaymentMethod = paymentTransaction.PaymentMethod;
                    model.PaymentMethod = "MercadoPago";

                    model.paymentToken      = paymentTransaction.paymentToken;
                    model.StatusDetail      = paymentTransaction.StatusDetail;
                    model.TransactionAmount = paymentTransaction.TransactionAmount;
                    if (paymentTransaction.UserId > 0)
                    {
                        model.UserId = paymentTransaction.UserId;
                    }
                    db.PaymentTransaction.Add(model);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Ok());
        }
示例#4
0
        public IActionResult addWithTrans([FromBody] VendorBalance model)
        {
            var result = new VendorTransaction();

            result.IsActive          = true;
            result.IsPaidByPistis    = true;
            result.TransactionDate   = DateTime.Now;
            result.TransactionNumber = model.Transno;
            result.VendorId          = model.VendorId;
            result.AmountPaid        = Convert.ToDecimal(model.Payment);
            db.VendorTransaction.Add(result);
            try
            {
                db.SaveChanges();
                var sum = db.VendorTransactionSummary.Where(x => x.IsActive == true && x.VendorId == model.VendorId).FirstOrDefault();
                if (sum != null)
                {
                    var pending = Convert.ToDecimal(sum.DueAmount - model.Payment);
                    sum.DueAmount       = pending;
                    sum.ModifyOn        = DateTime.Now;
                    db.Entry(sum).State = EntityState.Modified;
                    db.SaveChanges();
                }
                return(Ok(true));
            }
            catch (Exception ex)
            {
                return(Ok(false));
            }
        }
示例#5
0
 Boolean ReadMsg(List <VendorChatMsg> all, int VendorId)
 {
     if (VendorId != 0)
     {
         foreach (var a in all)
         {
             a.IsVendorRead = true;
         }
     }
     else
     {
         foreach (var a in all)
         {
             a.IsCustomerRead = true;
         }
     }
     try
     {
         db.Entry(all).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
示例#6
0
        private static Boolean saveInDb(PistisContext db, Message msg)
        {
            var model = new VendorChat();

            model.CustomerId             = msg.CustomerId;
            model.IsActive               = true;
            model.ProductVariantDetailId = msg.ProductVariantDetailId;
            model.VendorId               = msg.VendorId;
            model.IpAddress              = msg.IpAddress;
            model.IsArchieved            = false;
            model.ProductVariantDetailId = msg.ProductVariantDetailId;
            db.VendorChat.Add(model);
            try
            {
                db.SaveChanges();
                var data = new VendorChatMsg();
                data.CustomerMsg    = msg.CustomerMsg;
                data.DateTime       = DateTime.Now;
                data.IsCustomerRead = false;
                data.IsVendorRead   = false;
                data.VendorChatId   = model.Id;
                data.VendorMsg      = msg.VendorMsg;
                db.VendorChatMsg.Add(data);
                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
示例#7
0
        public IActionResult refund(decimal amount, int id)
        {
            var data = db.Return.Where(x => x.Id == id && x.IsActive == true).FirstOrDefault();

            if (data != null)
            {
                var check = db.CheckoutItems.Where(x => x.Id == data.CheckoutItemId).FirstOrDefault();
                if (check != null)
                {
                    var tran = db.PaymentTransaction.Where(x => x.CheckoutId == check.CheckoutId).FirstOrDefault();
                    if (tran != null)
                    {
                        var sdk    = sdkdata();
                        var refund = new Refund(sdk);

                        Payment payment = new Payment(sdk);
                        var     pay     = Payment.FindById(Convert.ToInt64(tran.paymentID), sdk);
                        // var refund = new Payment(sdk).Refund();
                        refund.Amount = amount;
                        refund.manualSetPaymentId(Convert.ToDecimal(tran.paymentID));
                        refund.Save();

                        //var r = payment.Refund(amount);
                        if (refund != null)
                        {
                            try
                            {
                                var model = new PaymentTransaction();
                                model.CheckoutId        = tran.CheckoutId;
                                model.intent            = "refund";
                                model.payerID           = tran.payerID;
                                model.ReturnId          = refund.Id.ToString();
                                model.PaymentMethod     = tran.PaymentMethod;
                                model.StatusDetail      = "approved";
                                model.TransactionAmount = amount;
                                model.UserId            = tran.UserId;


                                db.PaymentTransaction.Add(model);
                                db.SaveChanges();


                                //return table
                                data.IsPaid          = true;
                                db.Entry(data).State = EntityState.Modified;
                                db.SaveChanges();
                            }
                            catch (Exception ex)
                            {
                                return(Ok(ex));
                            }
                        }
                        return(Ok(refund));
                    }
                }
            }
            return(Ok());
        }
示例#8
0
        public IActionResult addtag(int productId, string tagname)
        {
            var message = 0;

            try
            {
                if (tagname != null)
                {
                    var data = db.ProductRelatedTagMap.Where(x => x.RelatedTag.Name.ToLower() == tagname.ToLower()).FirstOrDefault();
                    if (data != null)
                    {
                        string[] words = tagname.Split(',');
                        foreach (var item in words)
                        {
                            var filterData = db.RelatedTag.Where(x => x.Name.ToLower() == item.ToLower() && x.Id == data.RelatedTagId).FirstOrDefault();
                            if (filterData != null)
                            {
                                filterData.Name = item;
                                db.SaveChanges();
                                var gettags = db.ProductRelatedTagMap.Where(x => x.RelatedTagId == filterData.Id && x.ProductId == productId).FirstOrDefault();

                                gettags.RelatedTagId = filterData.Id;
                                gettags.ProductId    = productId;
                                db.SaveChanges();
                            }
                        }
                    }
                    else
                    {
                        string[] words = tagname.Split(',');
                        foreach (var item in words)
                        {
                            RelatedTag tag = new RelatedTag();
                            tag.Name     = item;
                            tag.IsActive = true;
                            db.RelatedTag.Add(tag);
                            db.SaveChanges();
                            ProductRelatedTagMap gettags = new ProductRelatedTagMap();
                            gettags.RelatedTagId = tag.Id;
                            gettags.ProductId    = productId;
                            db.ProductRelatedTagMap.Add(gettags);
                            db.SaveChanges();
                        }
                    }


                    message = 1;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Ok(message));
        }
示例#9
0
        public async Task <IActionResult> generateOtp(int UserId, string Email)
        {
            var email = "";
            var check = new User();

            try
            {
                check = db.Users.Where(x => x.Id == UserId && x.RoleId == 1 && x.IsActive == true).FirstOrDefault();
                if (check != null)
                {
                    check.Otp = GenerateNumericOTP();
                    db.SaveChanges();
                    if (check != null)
                    {
                        var html = System.IO.File.ReadAllText(environment.WebRootPath + "/Template/otp.html");

                        html = html.Replace("{{userName}}", check.FirstName);
                        html = html.Replace("{{otp}}", check.Otp);

                        Emailmodel emailmodel = new Emailmodel();
                        emailmodel.From    = "";
                        emailmodel.To      = Email;
                        emailmodel.Subject = "One Time Password";
                        //   emailmodel.Body = "As you requested, your One Time Password for your account has now been reset." + check.Otp + " .If it was not at your request, then please contact support immediately.";
                        emailmodel.Body = html;
                        emailmodel.key  = "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";
                        //   SmtpClient ObjSmtpClient = new SmtpClient(_settings.Value.SMTPADDRESS, 587);
                        // ObjSmtpClient.Credentials = new System.Net.NetworkCredential(_settings.Value.SMTPUSERNAME.ToString(), _settings.Value.SMTPPASSWORD.ToString());
                        // ObjSmtpClient.EnableSsl = true;
                        // var key = _settings.Value.SENDGRID_API_KEY;

                        await Example.Execute(emailmodel);

                        //  ObjSmtpClient.UseDefaultCredentials = false;
                        //  ObjSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                        try
                        {
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    return(Ok(check));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Ok(0));
        }
示例#10
0
 public IActionResult Add(ProductCategoryCommission model)
 {
     model.IsActive = true;
     try
     {
         db.ProductCategoryCommission.Add(model);
         db.SaveChanges();
         obj.CategoryCommissions = null;
         return(Ok(true));
     }
     catch (Exception ex)
     {
         return(Ok(false));
     }
 }
示例#11
0
        public int saveLog(Log log)
        {
            int response = 0;

            try
            {
                var obj = new Log();
                if (log != null)
                {
                    obj.IpAddress      = log.IpAddress ?? "";
                    obj.UserId         = log.UserId ?? 0;
                    obj.LogtypeId      = log.LogtypeId ?? 0;
                    obj.Action         = log.Action ?? "";
                    obj.Description    = log.Description ?? "";
                    obj.Result         = log.Result ?? "";
                    obj.ActionDateTime = DateTime.Now;
                    obj.IsActive       = true;
                    db.Log.Add(obj);
                    db.SaveChanges();
                    response = 1;
                }
                return(response);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#12
0
        public Models.FooterUrl deleteFooter(int Id)
        {
            var obj = db.FooterUrls.Where(x => x.Id == Id).FirstOrDefault();

            if (obj != null)
            {
                obj.IsActive = false;
            }
            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            { }
            return(obj);
        }
示例#13
0
    public PaymentTransaction PaymentAdd(Payment pay, int userid, int paymenttype)
    {
        var model = new PaymentTransaction();

        model.FeesAmount        = Convert.ToInt32(pay.FeeDetails[0].Amount);
        model.intent            = "sale";
        model.orderID           = pay.Id.ToString();
        model.payerID           = pay.Payer.Id;
        model.paymentID         = pay.Id.ToString();
        model.PaymentMethod     = pay.PaymentMethodId;
        model.StatusDetail      = pay.StatusDetail;
        model.TransactionAmount = Convert.ToDecimal(pay.TransactionAmount);
        model.UserId            = userid;
        model.PaymentTypeId     = paymenttype;
        try
        {
            db.PaymentTransaction.Add(model);
            db.SaveChanges();


            return(model);
        }
        catch (Exception ex)
        {
            return(model);
        }
    }
示例#14
0
        public IActionResult Add(testi model)
        {
            int result = 0;

            if (model.UserId > 0)
            {
                var testimonial = db.Testimonial.Where(x => x.IsActive == true && x.UserId == model.UserId).FirstOrDefault();
                if (testimonial == null)
                {
                    var data = new Models.Testimonial();
                    data.Description = model.Description;
                    data.CreatedOn   = DateTime.Now;
                    data.IsApproved  = false;

                    data.Rating    = model.Rating;
                    data.UpdatedOn = DateTime.Now;
                    data.UserId    = model.UserId;
                    data.IsActive  = true;
                    db.Testimonial.Add(data);
                    result = db.SaveChanges();
                }
                else
                {
                    testimonial.Description = model.Description;
                    testimonial.CreatedOn   = testimonial.CreatedOn;
                    testimonial.IsApproved  = false;
                    if (model.Rating != 0)
                    {
                        testimonial.Rating = model.Rating;
                    }
                    testimonial.UpdatedOn = DateTime.Now;
                    testimonial.UserId    = model.UserId;
                    testimonial.IsActive  = true;
                    result = db.SaveChanges();
                }
            }

            try
            {
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
示例#15
0
        public FeatureProduct deleteFeatureProduct(int ProductId)
        {
            var obj = db.FeatureProducts.Where(x => x.ProductId == ProductId).FirstOrDefault();

            if (obj != null)
            {
                obj.IsActive = false;
            }
            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
            }
            return(obj);
        }
示例#16
0
 public FooterHeader saveProduct(string Name)
 {
     Models.FooterHeader footerHeader = new Models.FooterHeader();
     if (!string.IsNullOrEmpty(Name))
     {
         footerHeader.Name = Name;
     }
     footerHeader.IsActive = true;
     try
     {
         db.FooterHeaders.Add(footerHeader);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
     return(footerHeader);
 }
示例#17
0
        public int CompareProduct(int variantId, int UserId, string IpAddress)
        {
            var message  = 0;
            var counting = new List <CompareProduct>();

            try
            {
                if (variantId > 0)

                {
                    var obj = db.CompareProducts.Where(x => x.ProductVariantDetailId == variantId && x.IsActive == true && (x.UserId == UserId || x.IpAddress == IpAddress)).ToList();
                    if (obj.Count == 0)
                    {
                        var SaveProduct = new CompareProduct();
                        SaveProduct.ProductVariantDetailId = variantId;
                        SaveProduct.IsActive = true;
                        if (IpAddress != null)
                        {
                            SaveProduct.IpAddress = IpAddress;
                        }
                        if (UserId > 0)
                        {
                            SaveProduct.UserId = UserId;
                        }
                        db.Add(SaveProduct);
                        db.SaveChanges();
                        var actionResult   = CompareProducts(UserId, IpAddress);
                        var okObjectResult = actionResult as OkObjectResult;

                        var model = okObjectResult.Value as  List <product1>;

                        message = model.Count;
                    }
                    //  counting = db.CompareProducts.Where(x => x.IsActive == true && (x.UserId == UserId || x.IpAddress == IpAddress)).ToList();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(message);
        }
示例#18
0
        public int deleteCustomerGroup(int groupId)
        {
            var message = 0;
            var data    = new CustomerGroup();

            if (groupId > 0)
            {
                data = db.CustomerGroups.Where(x => x.Id == groupId).FirstOrDefault();
            }
            if (data != null)
            {
                data.IsActive = false;
            }
            var obj = db.CustomerGroupUsers.Where(x => x.CustomerGroupId == groupId).ToList();

            if (obj != null)
            {
                foreach (var item in obj)
                {
                    item.IsActive = false;
                    message       = 1;
                }
            }
            try
            {
                db.SaveChanges();
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
            return(message);
        }
示例#19
0
 public IActionResult save(Review Review)
 {
     try
     {
         var data  = new Models.RatingReview();
         var check = db.RatingReviews.Where(x => x.ProductId == Review.ProductId && x.UserId == Review.UserId)
                     .FirstOrDefault();
         if (check != null)
         {
             check.ProductId  = Review.ProductId;
             check.UserId     = Review.UserId;
             check.Review     = Review.review;
             check.IsActive   = true;
             check.ReviewDate = DateTime.Now;
             check.Rating     = Review.Rating;
             check.IsDefault  = true;
             if (Review.ReviewStatusId != 0)
             {
                 check.ReviewStatusId = Review.ReviewStatusId;
             }
             db.SaveChanges();
         }
         else
         {
             data.ProductId  = Review.ProductId;
             data.UserId     = Review.UserId;
             data.Review     = Review.review;
             data.IsActive   = true;
             data.ReviewDate = DateTime.Now;
             data.Rating     = Review.Rating;
             db.RatingReviews.Add(data);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(Ok());
 }
示例#20
0
        public IActionResult deleteById(int id)
        {
            var data = db.CategoryVariants.Where(c => c.Id == id).Include(c => c.Variant).Include(v => v.Variant.VariantOptions).FirstOrDefault();

            if (data != null)
            {
                data.IsActive = false;
                if (data.Variant != null)
                {
                    data.IsActive = false;
                    if (data.Variant.VariantOptions != null && data.Variant.VariantOptions.Count > 0)
                    {
                        foreach (var item in data.Variant.VariantOptions)
                        {
                            item.IsActive = false;
                        }
                    }
                }
                db.SaveChanges();
            }
            return(Ok(true));
        }
示例#21
0
        public static bool saveNotification(Notification model, PistisContext context, List <int> users)
        {
            if (model != null)
            {
                try
                {
                    context.Notifications.Add(model);
                    context.SaveChanges();


                    if (users.Count > 0)
                    {
                        List <NotificationUser> allUsers = new List <NotificationUser>();
                        foreach (var item in users)
                        {
                            var userNotification = new NotificationUser();
                            userNotification.NotificationId = model.Id;
                            userNotification.UserId         = item;
                            userNotification.IsActive       = true;
                            userNotification.IsRead         = false;
                            userNotification.IsDeleted      = false;
                            userNotification.CreatedDate    = System.DateTime.Now;
                            allUsers.Add(userNotification);
                        }
                        if (allUsers.Count == users.Count)
                        {
                            context.NotificationUser.AddRange(allUsers);
                            context.SaveChanges();
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(true);
        }
示例#22
0
        public IActionResult readNotification(int id)
        {
            var data = db.NotificationUser.Where(b => b.Id == id).FirstOrDefault();

            if (data != null)
            {
                try
                {
                    data.IsRead   = true;
                    data.ReadDate = System.DateTime.Now;
                    db.SaveChanges();
                    return(Ok(true));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                return(Ok(false));
            }
        }
示例#23
0
        public IActionResult deleteById(int id)
        {
            var data = db.Deal.Where(c => c.Id == id).FirstOrDefault();

            if (data != null)
            {
                data.IsActive = false;
                db.SaveChanges();
            }
            return(Ok(true));
        }
示例#24
0
 public CustomerHistory CustomerHistory([FromBody] custom data)
 {
     Models.CustomerHistory customerHistory = new CustomerHistory();
     if (data != null)
     {
         customerHistory.CustomerId = data.customerId;
         customerHistory.ProductId  = data.ProductId;
         customerHistory.IpAddress  = data.IpAddress;
         customerHistory.Date       = DateTime.Now;
         customerHistory.IsActive   = true;
     }
     try
     {
         db.CustomerHistories.Add(customerHistory);
         db.SaveChanges();
         return(customerHistory);
     }
     catch (Exception ex)
     {
         Console.Write(ex);
         return(customerHistory);
     }
 }
示例#25
0
        public async Task <IActionResult> UpdateProductImages()
        {
            try
            {
                JsonResult response = null;

                var count     = 0;
                var allImages = db.ProductImages.Where(x => x.ImagePath150x150 == "").ToList();
                foreach (var img in allImages)
                {
                    //if (img.ImagePath150x150 == null)
                    //{
                    try
                    {
                        var bytes = await S3Service.GetReaderFromS3(img.ImagePath);

                        var base64        = GetBase64StringForImage(bytes);
                        var imageResponse = await S3Service.updateUploadObject150(base64, img.ImagePath.Split('/')[3]);

                        var imageResponse1 = await S3Service.updateUploadObject450(base64, img.ImagePath.Split('/')[3]);

                        response = new JsonResult(new Object());
                        if (imageResponse.Success)
                        {
                            //img.ImagePath = $"https://pistis.s3.us-east-2.amazonaws.com/{imageResponse.FileName}";
                            img.ImagePath150x150 = $"https://pistis150x150.s3.us-east-2.amazonaws.com/{imageResponse.FileName}";
                            img.ImagePath450x450 = $"https://pistis450x450.s3.us-east-2.amazonaws.com/{imageResponse.FileName}";
                            db.SaveChanges();
                            count++;
                        }
                    }
                    catch (Exception ext)
                    {
                        img.ImagePath150x150 = $"https://pistis150x150.s3.us-east-2.amazonaws.com/{img.ImagePath.Split('/')[3]}";
                        img.ImagePath450x450 = $"https://pistis450x450.s3.us-east-2.amazonaws.com/{img.ImagePath.Split('/')[3]}";
                        db.SaveChanges();
                        count++;
                    }

                    //}
                }

                //var products = db.Products.Include(m => m.ProductVariantDetails).ToList().Take(100).ToList();


                //var images = db.ProductImages.ToList();
                //foreach (var prod in products)
                //    foreach (var variant in prod.ProductVariantDetails)
                //    {
                //        variant.ProductImages = new List<ProductImage>();
                //        variant.ProductImages = images.Where(n => n.ProductVariantDetailId == variant.Id).ToList();

                //    }


                //foreach (var item in products)
                //{
                //    foreach (var variant in item.ProductVariantDetails)
                //    {
                //        foreach (var img in variant.ProductImages)
                //        {
                //            var bytes = await S3Service.GetReaderFromS3(img.ImagePath);
                //            var base64 = GetBase64StringForImage(bytes);
                //            var imageResponse = await S3Service.UploadObjectNew(base64, img.ImagePath.Split('/')[3]);

                //            response = new JsonResult(new Object());
                //            if (imageResponse.Success)
                //            {
                //                //img.ImagePath = $"https://pistis.s3.us-east-2.amazonaws.com/{imageResponse.FileName}";
                //                img.ImagePath150x150 = $"https://pistis150x150.s3.us-east-2.amazonaws.com/{imageResponse.FileName}";
                //                img.ImagePath450x450 = $"https://pistis450x450.s3.us-east-2.amazonaws.com/{imageResponse.FileName}";
                //            }
                //        }
                //        db.SaveChanges();
                //    }
                //}
            }
            catch (Exception ex)
            {
                //return Ok(ex);
            }
            return(Ok("Image updated successfully"));
        }
示例#26
0
        public async Task <IActionResult> RegisterCustomer(RegisterCustomer model)
        {
            var user          = new User();
            var salt          = CommonFunctions.CreateSalt(64); //Generate a cryptographic random number.
            var hashAlgorithm = new SHA512HashAlgorithm();
            var data          = db.Users.Where(x => x.Email == model.Email && x.IsActive == true && x.RoleId == 1).FirstOrDefault();

            if (data == null)
            {
                user = new User()
                {
                    FirstName    = model.FirstName,
                    MiddleName   = model.MiddleName,
                    LastName     = model.LastName,
                    Email        = model.Email,
                    Phone        = model.Phone,
                    PasswordHash = hashAlgorithm.GenerateSaltedHash(CommonFunctions.GetBytes(model.Password), salt),
                    PasswordSalt = salt,
                    RoleId       = 1,
                    IsVerified   = true,
                    IsActive     = true,
                    DateTime     = DateTime.Now
                };
                db.Users.Add(user);
                db.SaveChanges();
                MailAddress objFrom = new MailAddress(_settings.Value.ADMINEMAIL, "info@eschedule");
                MailMessage mailMsg = new MailMessage();
                mailMsg.From = objFrom;
                var html = System.IO.File.ReadAllText(environment.WebRootPath + "/Template/UserRegister.html");

                html = html.Replace("{{userName}}", user.FirstName);
                Emailmodel emailmodel = new Emailmodel();
                emailmodel.From    = "";
                emailmodel.To      = user.Email;
                emailmodel.Subject = " Congratulations, Registered Successfully";
                emailmodel.Body    = html;
                emailmodel.key     = "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";
                await Example.Execute(emailmodel);

                user.ReturnCode    = 0;
                user.ReturnMessage = "You are registered successfully";
            }
            else
            {
                user.ReturnCode    = -1;
                user.ReturnMessage = "Email is already registered";
            }
            try
            {
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(Ok(user));
        }
示例#27
0
        public IActionResult addNewsletter([FromBody] Template template)
        {
            var data    = new Template();
            var message = 0;

            try
            {
                if (template != null)
                {
                    if (template.Id > 0)
                    {
                        var check = db.Template.Where(x => x.IsActive == true && x.Id == template.Id).FirstOrDefault();
                        check.SenderName = template.SenderName;
                        if (template.TemplateContent != null)
                        {
                            check.TemplateContent = template.TemplateContent;
                        }
                        if (template.TemplateSubject != null)
                        {
                            check.TemplateSubject = template.TemplateSubject;
                        }
                        if (template.Templatetype != null)
                        {
                            check.Templatetype = template.Templatetype;
                        }
                        if (template.SenderEmail != null)
                        {
                            check.SenderEmail = template.SenderEmail;
                        }
                        data.IsActive = true;
                        db.SaveChanges();
                        message = 1;
                    }
                    else
                    {
                        if (template.SenderName != null)
                        {
                            data.SenderName = template.SenderName;
                        }
                        if (template.TemplateContent != null)
                        {
                            data.TemplateContent = template.TemplateContent;
                        }
                        if (template.TemplateSubject != null)
                        {
                            data.TemplateSubject = template.TemplateSubject;
                        }
                        if (template.Templatetype != null)
                        {
                            data.Templatetype = template.Templatetype;
                        }
                        if (template.SenderEmail != null)
                        {
                            data.SenderEmail = template.SenderEmail;
                        }
                        data.IsActive = true;
                        db.Template.Add(data);
                        db.SaveChanges();
                        message = 2;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Ok(message));
        }
示例#28
0
        public IActionResult UploadFile([FromBody] BannerImages model)
        {
            BannerImages bannerImages = new BannerImages();

            bannerImages.IsActive = true;
            bannerImages.Image    = model.Image;
            try
            {
                db.BannerImages.Add(bannerImages);
                db.SaveChanges();

                return(Ok(bannerImages));
            }
            catch (Exception ex)
            {
                Console.Write(ex);
                return(Ok(ex));
            }
        }
示例#29
0
        public IActionResult savelistdetails([FromBody] listDetails listDetails)
        {
            var message = 0;

            try
            {
                if (listDetails.OrderNumber > 0)
                {
                    var data      = db.HomeCategory.Where(x => x.OrderNumber == listDetails.OrderNumber && x.IsActive == true).FirstOrDefault();
                    var dataCount = db.HomeCategory.Where(x => x.IsActive == true).ToList();
                    if (data == null)
                    {
                        var Data = new Models.HomeCategory();
                        Data.OrderNumber = listDetails.OrderNumber;
                        Data.Name        = listDetails.listName;
                        Data.IsActive    = listDetails.IsActive;
                        Data.IsDesktop   = listDetails.IsDesktop;
                        Data.Shape       = listDetails.Shape == "Circle" ? "Circle" : listDetails.Shape == "Square" ? "Square" : "Rectangular";
                        db.HomeCategory.Add(Data);
                        db.SaveChanges();
                        message = 1;
                    }
                    else
                    {
                        // var oldOrderNumber = data.OrderNumber;
                        // var oldName = data.Name;
                        //var oldIsactive = data.IsActive;
                        //  data.IsActive = false;
                        //    db.SaveChanges();
                        //first false and store infor
                        var Data = new Models.HomeCategory();

                        Data.IsDesktop   = listDetails.IsDesktop;
                        Data.Shape       = listDetails.Shape == "Circle" ? "Circle" : listDetails.Shape == "Square" ? "Square" : "Rectangular";
                        Data.OrderNumber = listDetails.OrderNumber;
                        Data.Name        = listDetails.listName;
                        Data.IsActive    = listDetails.IsActive;
                        db.HomeCategory.Add(Data);
                        db.SaveChanges();
                        //seconed add the new one

                        var newOrderNumberforOld = dataCount.Count() + 1;
                        //var Data2 = new Models.HomeCategory();
                        //Data2.IsActive = true;
                        //Data2.Name = oldName;
                        //Data2.OrderNumber = newOrderNumberforOld;
                        //db.HomeCategory.Add(Data2);
                        data.OrderNumber = newOrderNumberforOld;
                        db.SaveChanges();
                        message = 1;
                        //add the old one with count +1 ordernumber
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            var newList = db.HomeCategory.ToList();

            return(Ok(newList));
        }
示例#30
0
 public IActionResult updatePromotions(int Id)
 {
     try
     {
         var spinnerOptionChances = db.SpinnerOptionsPeriod.Where(x => x.SpinnerPromotionId == Id).FirstOrDefault();
         if (spinnerOptionChances != null)
         {
             spinnerOptionChances.Chances = --spinnerOptionChances.Chances;
             if (spinnerOptionChances.Chances == 0)
             {
                 spinnerOptionChances.IsActive = false;
             }
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(Ok());
 }