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); }
public int CreateSite(int clientId, string siteName, string salesForceId) { try { return(SiteService.CreateSite(clientId, siteName, salesForceId)); } catch (Exception) { throw; } }
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); }
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)); }