public IActionResult AddSubscriber(Subscriber subscriber)
        {
            var ip_address = HttpContext.Connection.RemoteIpAddress.ToString();

            subscriber.IpAddress = ip_address;

            if (string.IsNullOrEmpty(subscriber.Name))
            {
                subscriber.Name = "NA";
            }

            if (repositoryData.IsSubscriberExist(subscriber.EmailId))
            {
                return(Json(new { success = false, message = "Emailid already subscribed." }));
            }

            repositoryData.AddSubscriber(subscriber);
            repositoryData.Commit();

            return(Json(new { success = true, message = "Thank you for subscribing us." }));

            //return new ContentResult
            //{
            //    StatusCode = 200,
            //    ContentType = "application/xml",
            //    Content = strContent,

            //};
        }
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (Categories.CategoryId > 0)
            {
                repositoryData.UpdateCategory(Categories);
            }
            else
            {
                repositoryData.AddCategory(Categories);
            }

            int temp = repositoryData.Commit();

            if (temp > 0)
            {
                Message = "Category " + Categories.Name + " is saved successfully.";
            }
            else
            {
                Message = "Error occurs, pls try again later.";
            }
            return(RedirectToPage("Upsert", new { CategoryId = Categories.CategoryId }));
        }
Exemple #3
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }


            if (demos.DemoId > 0)
            {
                repositoryData.UpdateDemo(demos);
            }
            else
            {
                repositoryData.AddDemo(demos);
            }

            int temp = repositoryData.Commit();

            if (temp > 0)
            {
                Message = "Data saved successfully.";
            }
            else
            {
                Message = "Eoor occurs, pls try again later.";
            }
            return(RedirectToPage("Upsert", new { DemoId = demos.DemoId }));
        }
        public IActionResult OnPostComments(Comments comments)
        {
            var cmt_ip = HttpContext.Connection.RemoteIpAddress.ToString();

            comments.Status         = "0";
            comments.AuthorIp       = cmt_ip;
            comments.CommentDate    = DateTime.Now;
            comments.CommentDateGmt = DateTime.Now.ToUniversalTime();

            repositoryData.AddComments(comments);
            int result = repositoryData.Commit();

            if (result > 0)
            {
                return(Json(new { success = true, message = "Your comments added successfully" }));
            }

            return(Json(new { success = false, message = "Error while adding comments. Pls tyr again later." }));
        }