Пример #1
0
        public void Create_site_test()
        {
            HttpContext.Current = new HttpContext(
                new HttpRequest("", "http://google.com", ""),
                new HttpResponse(new StringWriter())
                );

            Site site = new Site()
            {
                Url         = "www.google.com/sitemap.xml",
                RequestIp   = "10.0.0.1",
                Id          = 1,
                SiteAmount  = 10,
                SummaryTime = 0
            };

            var siteMock        = new Mock <IRepository <Site> >();
            var mockSiteService = mockIUOW.Setup(x => x.Sites).Returns(siteMock.Object);

            mockIUOW.Setup(x => x.Sites.Create(site));
            var    siteService = new SiteService(mockIUOW.Object);
            string request     = "www.google.com/sitemap.xml";

            siteService.CreateSite(request);

            Assert.IsTrue(mockIUOW.Object.Sites != null);
            Assert.IsTrue(siteService.GetSites() != null);
        }
Пример #2
0
 public int CreateSite(int clientId, string siteName, string salesForceId)
 {
     try
     {
         return(SiteService.CreateSite(clientId, siteName, salesForceId));
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #3
0
        public ActionResult Create(Site model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var service = new SiteService(DataContext);
                    service.CreateSite(model);

                    ShowSuccess(MessageResource.CreateSuccess);

                    return RedirectToIndex();
                }
                catch (Exception e)
                {
                    LogError(e.ToString());
                    ShowError(MessageResource.CreateFailed);
                }
            }

            return View(model);
        }
Пример #4
0
        public ActionResult Create(Site model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var service = new SiteService(DataContext);
                    service.CreateSite(model);

                    ShowSuccess(MessageResource.CreateSuccess);

                    return(RedirectToIndex());
                }
                catch (Exception e)
                {
                    LogError(e.ToString());
                    ShowError(MessageResource.CreateFailed);
                }
            }

            return(View(model));
        }