public SiteBL SaveSiteAndPages(IEnumerable <PageBL> pages, SiteBL siteModel)
        {
            var site = Create(siteModel);

            foreach (var page in pages)
            {
                if (page != null)
                {
                    page.SiteId = site.Id;
                    var pageToCreate = _mapper.Map <Page>(page);
                    _pageRepository.Create(pageToCreate);
                }
            }

            site.MaxResponseTime = _pageRepository.GetFastestResponceTime(site.Id);

            site.MinResponseTime = _pageRepository.GetSlowestResponceTime(site.Id);

            var siteToUpdate = _mapper.Map <Site>(site);

            _siteRepository.Update(siteToUpdate);

            var siteWithLinks = _siteRepository.GetById(siteToUpdate.Id);

            var siteToReturn = _mapper.Map <SiteBL>(siteWithLinks);

            return(siteToReturn);
        }
Пример #2
0
        public ActionResult <SiteListResponseModel> GetListSite([FromBody] FilterBillboard filter)
        {
            SiteListResponseModel res = new SiteListResponseModel();

            try
            {
                SiteBL bl   = new SiteBL(DbContext);
                var    data = bl.GetListSite(filter);

                res.data       = data.Result;
                res.Message    = "Success";
                res.Response   = true;
                res.TotalPages = data.TotalPage;
                res.TotalData  = data.TotalData;


                return(Ok(res));
            }
            catch (Exception ex)
            {
                res.Message  = ex.Message;
                res.Response = false;

                return(BadRequest(res));
            }
        }
        public SiteBL Create(SiteBL site)
        {
            var siteToCreate = _mapper.Map <Site>(site);
            var siteDAL      = _siteRepository.Create(siteToCreate);
            var siteBL       = _mapper.Map <SiteBL>(siteDAL);

            return(siteBL);
        }
    public mySite GetSite(string siteID)
    {
        SiteBL _siteBL = new SiteBL();
        mySite ms      = new mySite();
        var    s       = _siteBL.GetSite(siteID);

        ms.SiteID = s.SiteAliasName;
        return(ms);
    }
Пример #5
0
        // TODO (brigettek): this feature currently always fails.  Commenting out until we need/fix it.
        //  [DreamFeature("POST:site/notifyadmin", "Notifies the site admin")]/
        //  [DreamFeatureParam("subject", "string", "Subject of the notice")]
        //  [DreamFeatureStatus(DreamStatus.Ok, "The request completed successfully")]
        //  [DreamFeatureStatus(DreamStatus.BadRequest, "Invalid input parameter or request body")]
        //  [DreamFeatureStatus(DreamStatus.Forbidden, "User must be logged in")]
        public Yield PostSiteNotifyAdmin(DreamContext context, DreamMessage request, Result <DreamMessage> response)
        {
            if ((DekiContext.CurrentOrNull == null) || UserBL.IsAnonymous(DekiContext.Current.User))
            {
                throw new SiteMustBeLoggedInForbiddenException();
            }
            var siteBL = new SiteBL();

            siteBL.SendNoticeToAdmin(context.GetParam("subject"), request.AsText(), request.ContentType);
            response.Return(DreamMessage.Ok());
            yield break;
        }
        public void CreateHistory(SiteBL site)
        {
            var history = new HistoryBL
            {
                Date            = DateTime.Now,
                MaxResponseTime = site.MaxResponseTime,
                MinResponseTime = site.MinResponseTime,
                SiteId          = site.Id,
                SiteURL         = site.Url
            };

            var historyToCreate = _mapper.Map <History>(history);

            _historyRepository.Create(historyToCreate);
        }
Пример #7
0
        public ActionResult <CheckDateAvailableResponseModel> CheckAvailableSite([FromBody] CheckDateAvailableInputModel data)
        {
            CheckDateAvailableResponseModel res = new CheckDateAvailableResponseModel();

            try
            {
                SiteBL bl   = new SiteBL(DbContext);
                var    temp = bl.CheckSiteAvailable(data);
                res.data = temp;

                res.Message  = "Success";
                res.Response = true;

                return(Ok(res));
            }
            catch (Exception ex)
            {
                res.Message  = ex.Message;
                res.Response = false;

                return(res);
            }
        }
Пример #8
0
        public ActionResult <SiteDetailResponseModel> GetSite([FromBody] SiteDetailInputModel data)
        {
            SiteDetailResponseModel res = new SiteDetailResponseModel();

            try
            {
                SiteBL bl   = new SiteBL(DbContext);
                var    temp = bl.GetSiteDetail(data);

                res.data     = temp;
                res.Message  = "Success";
                res.Response = true;

                return(res);
            }
            catch (Exception ex)
            {
                res.Message  = ex.Message;
                res.Response = false;

                return(res);
            }
        }
Пример #9
0
        public ActionResult <AddSiteResponseModel> AddSiteImage([FromBody] AddSiteResultImageInputModel data)
        {
            AddSiteResponseModel res = new AddSiteResponseModel();

            try
            {
                SiteBL bl = new SiteBL(DbContext);
                var    x  = bl.SaveImageSite(data);

                res.data     = x;
                res.Message  = "Success";
                res.Response = true;

                return(res);
            }
            catch (Exception ex)
            {
                res.Message  = ex.Message;
                res.Response = false;

                return(res);
            }
        }
Пример #10
0
        public ActionResult <EditSiteResponseModel> UpdateSite([FromBody] EditSiteResultInputModel data)
        {
            EditSiteResponseModel res = new EditSiteResponseModel();

            try
            {
                SiteBL bl   = new SiteBL(DbContext);
                var    temp = bl.Edit(data);

                res.data     = temp;
                res.Message  = "Success";
                res.Response = true;

                return(Ok(res));
            }
            catch (Exception ex)
            {
                res.Message  = ex.Message;
                res.Response = false;

                return(BadRequest(res));
            }
        }
Пример #11
0
        public ActionResult <ImportSiteResponseModel> ImportSite([FromBody] ImportSiteInputModel data)
        {
            ImportSiteResponseModel res = new ImportSiteResponseModel();

            LogAppBL blLog = new LogAppBL(DbContext);

            try
            {
                string message = data.UserID + " Start upload excel list site";

                //blLog.SaveLog(LogAppEnum.StartUploadExcelSite, data.UserID, message);

                SiteBL bl = new SiteBL(DbContext);
                bl.ImportSite(data);

                ImportSiteOutputModel x = new ImportSiteOutputModel();
                x.ImportDate = DateTime.Now;

                res.data     = x;
                res.Message  = "Success upload file excel";
                res.Response = true;

                //blLog.SaveLog(LogAppEnum.EndUploadExcelSite, data.UserID, res.Message);

                return(res);
            }
            catch (Exception ex)
            {
                res.Message  = ex.Message;
                res.Response = false;

                //blLog.SaveLog(LogAppEnum.ErrorUploadExcelSite, data.UserID, ex.Message);

                return(res);
            }
        }
        public void Update(SiteBL site)
        {
            var siteToUpdate = _mapper.Map <Site>(site);

            _siteRepository.Update(siteToUpdate);
        }