Beispiel #1
0
 public bool PostSuccsessStory(SuccessStoryViewModel successStory)
 {
     using (var connection = new SqlConnection(connectionString))
     {
         try
         {
             SqlParameter[] parameters = new SqlParameter[] {
                 new SqlParameter("@Name", successStory.name),
                 new SqlParameter("@Email", successStory.Email),
                 new SqlParameter("@Message", successStory.Message),
                 new SqlParameter("@UserId", successStory.UserId),
                 //new SqlParameter("@Tagline",successStory.Tagline),
             };
             var result =
                 SqlHelper.ExecuteNonQuery
                 (
                     connection,
                     CommandType.StoredProcedure,
                     "usp_PostSuccessStory",
                     parameters
                 );
             if (result > 0)
             {
                 return(true);
             }
         }
         finally
         {
             SqlHelper.CloseConnection(connection);
         }
     }
     throw new UserCanNotPostData("Unable to post data");
 }
Beispiel #2
0
        public IActionResult PostSucessStoryReview(SuccessStoryViewModel model)
        {
            bool isPosted     = false;
            var  user         = HttpContext.Session.Get <UserViewModel>(Constants.SessionKeyUserInfo);
            var  successStory = new SuccessStoryViewModel
            {
                name    = user.FirstName,
                Email   = user.Email,
                city    = user.City,
                Tagline = model.Tagline,
                Message = model.Message,
                UserId  = user.UserId
            };

            try
            {
                isPosted = _homeHandler.PostSuccessStory(successStory);
                if (isPosted)
                {
                    TempData["Feedback"] = "Thank you for posting your feedback.";
                }
                else
                {
                    TempData["Feedback"] = "Review could not post. Please try again.";
                }
            }
            catch (UserCanNotPostData ex)
            {
                Logger.Logger.WriteLog(Logger.Logtype.Error, ex.Message, user == null ? 0 : user.UserId, typeof(HomeController), ex);
                ModelState.AddModelError("ErrorMessage", string.Format("{0}", ex.Message));
                isPosted = false;
            }

            return(RedirectToAction("SucessStoryAndReview"));
        }
        public List <SuccessStoryViewModel> GetSuccussStory()
        {
            DataTable successStories = _homeRepositories.GetSuccessStory();
            List <SuccessStoryViewModel> lstsuccessStory = new List <SuccessStoryViewModel>();

            if (successStories.Rows.Count > 0)
            {
                DataTable dt = successStories;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string picpath = System.IO.Path.GetFullPath(hostingEnviroment.WebRootPath + dt.Rows[i]["ProfilePic"]);
                    if (!System.IO.File.Exists(picpath))
                    {
                        string fName = $@"\ProfilePic\" + "Avatar.jpg";
                        dt.Rows[i]["ProfilePic"] = fName;
                    }
                    SuccessStoryViewModel successStory = new SuccessStoryViewModel
                    {
                        Email = Convert.ToString(dt.Rows[i]["Email"]),
                        //city = Convert.ToString(dt.Rows[i]["City"]),
                        name        = Convert.ToString(dt.Rows[i]["FirstName"]),
                        Tagline     = Convert.ToString(dt.Rows[i]["TagLine"]),
                        Message     = Convert.ToString(dt.Rows[i]["Message"]),
                        CreatedDate = Convert.ToDateTime(dt.Rows[i]["CreatedDate"]),
                        ImgUrl      = Convert.ToString(dt.Rows[i]["ProfilePic"]),
                    };
                    lstsuccessStory.Add(successStory);
                }
            }
            return(lstsuccessStory);
        }
Beispiel #4
0
        public List <SuccessStoryViewModel> GetSuccussStory()
        {
            DataTable successStories = _homeRepositories.GetSuccessStory();
            List <SuccessStoryViewModel> lstsuccessStory = new List <SuccessStoryViewModel>();

            if (successStories.Rows.Count > 0)
            {
                DataTable dt = successStories;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    SuccessStoryViewModel successStory = new SuccessStoryViewModel
                    {
                        Email = Convert.ToString(dt.Rows[i]["Email"]),
                        //city = Convert.ToString(dt.Rows[i]["City"]),
                        name        = Convert.ToString(dt.Rows[i]["FirstName"]),
                        Tagline     = Convert.ToString(dt.Rows[i]["TagLine"]),
                        Message     = Convert.ToString(dt.Rows[i]["Message"]),
                        CreatedDate = Convert.ToDateTime(dt.Rows[i]["CreatedDate"]),
                        ImgUrl      = Convert.ToString(dt.Rows[i]["ProfilePic"]),
                    };
                    lstsuccessStory.Add(successStory);
                }
            }
            return(lstsuccessStory);
        }
Beispiel #5
0
 public void Create(SuccessStoryViewModel submittedStory)
 {
     if (ModelState.IsValid)
     {
         Message = _successStoryService.CreateSuccessStory(submittedStory, HttpContext.Request.Url.GetLeftPart(UriPartial.Authority));
         _notificationService.CreateMessageJobAndSendForExecution(Message);
     }
 }
        public bool PostSuccessStory(SuccessStoryViewModel model)
        {
            bool isSuccessStory = _homeRepositories.PostSuccsessStory(model);

            if (isSuccessStory)
            {
                return(true);
            }
            throw new UserCanNotPostData("Unable to post data");
        }
        public async Task Create_CallsService()
        {
            var context = new Mock <HttpContextBase>();
            var request = new Mock <HttpRequestBase>();

            request.Setup(r => r.Url).Returns(new Uri("http://www.google.com"));
            context
            .Setup(c => c.Request)
            .Returns(request.Object);
            _successStoryServiceMock.Setup(x => x.CreateSuccessStory(It.IsAny <SuccessStoryViewModel>(), It.IsAny <string>()));
            var story = new SuccessStoryViewModel();
            var cntlr = new SubmitStoryController(_successStoryServiceMock.Object, _notificationServiceMock.Object);

            cntlr.ControllerContext = new ControllerContext(context.Object, new RouteData(), cntlr);
            cntlr.Create(story);

            _successStoryServiceMock.Verify(x => x.CreateSuccessStory(It.IsAny <SuccessStoryViewModel>(), It.IsAny <string>()), Times.Once);
        }
Beispiel #8
0
        public string CreateSuccessStory(SuccessStoryViewModel submittedStory, string domain)
        {
            var message = String.Empty;

            try
            {
                var providerName = String.Empty;

                var transactionName = $"storyTransaction_{DateTime.Now}";
                var versionManager  = VersionManager.GetManager(null, transactionName);

                DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName, transactionName);
                Type           successStoryType           = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.SuccessStories.SuccessStory");
                DynamicContent successStoryItem           = dynamicModuleManager.CreateDataItem(successStoryType);

                successStoryItem.SetValue("Title", submittedStory.Title);
                successStoryItem.SetValue("Description", submittedStory.Description);
                successStoryItem.SetValue("SummaryDescription", submittedStory.SummaryDescription);
                successStoryItem.SetValue("ProductsUsed", submittedStory.ProductsUsed);
                successStoryItem.SetValue("Company", submittedStory.Company);
                successStoryItem.SetValue("CompanyWebsite", submittedStory.CompanyWebsite);
                successStoryItem.SetValue("Industry", submittedStory.Industry);

                LibrariesManager thumbnailManager = LibrariesManager.GetManager();

                if (submittedStory.Thumbnail != null)
                {
                    var fileStream = submittedStory.Thumbnail.InputStream;
                    var imgId      = Guid.NewGuid();
                    CreateImageWithNativeAPI(imgId, submittedStory.Title, fileStream, submittedStory.Thumbnail.FileName, Path.GetExtension(submittedStory.Thumbnail.FileName));
                    var thumbnailItem = thumbnailManager.GetImage(imgId);
                    if (thumbnailItem != null)
                    {
                        successStoryItem.CreateRelation(thumbnailItem, "Thumbnail");
                    }
                }

                successStoryItem.SetString("UrlName", $"{submittedStory.Title}-{submittedStory.Company}");
                successStoryItem.SetValue("Owner", SecurityManager.GetCurrentUserId());
                successStoryItem.SetValue("PublicationDate", DateTime.UtcNow);

                successStoryItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Draft");

                versionManager.CreateVersion(successStoryItem, false);

                ILifecycleDataItem publishedCarItem = dynamicModuleManager.Lifecycle.Publish(successStoryItem);

                successStoryItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Published");

                versionManager.CreateVersion(successStoryItem, true);

                TransactionManager.CommitTransaction(transactionName);
                message = $"A new Success Story has been submitted. Take a look <a style=\"font-weight:bold;color:blue;\" href=\"{domain}/success-story-details{successStoryItem.ItemDefaultUrl.Value}\">here</a>";
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            }

            return(message);
        }
Beispiel #9
0
        public ActionResult Index()
        {
            var story = new SuccessStoryViewModel();

            return(View(story));
        }