예제 #1
0
        public void SetRouterActionUrl(RouterAction ra)
        {
            var db = new GloshareDbContext();

            var routeraction = db.RouterActions.Find(ra.RouterActionId);

            routeraction.PostedUrl = ra.PostedUrl;

            db.SaveChanges();
        }
예제 #2
0
        public RouterAction SetSurveyAction(int routerContactId, int hostId, int projectId, string surveyUrl, string ipAddress)
        {
            var          db = new GloshareDbContext();
            RouterAction ra = null;

            RouterHost host = (RouterHost)hostId;

            if (host == RouterHost.PrecisionSample)
            {
                ra = db.RouterActions.FirstOrDefault(s =>
                                                     s.RouterContactId == routerContactId && s.RouterHostId == hostId && s.RouterSurveyPrecisionSample.ProjectId == projectId);
            }

            if (host == RouterHost.YourSurvey)
            {
                ra = db.RouterActions.FirstOrDefault(s =>
                                                     s.RouterContactId == routerContactId && s.RouterHostId == hostId && s.RouterSurveyYourSurvey.ProjectId == projectId);
            }

            if (ra == null)
            {
                int?psID = null;
                int?ysID = null;
                if (host == RouterHost.PrecisionSample)
                {
                    psID = db.RouterSurveyPrecisionSamples.FirstOrDefault(s => s.ProjectId == projectId)?.RouterSurveyPrecisionSampleId;
                }

                if (host == RouterHost.YourSurvey)
                {
                    ysID = db.RouterSurveyYourSurveys.FirstOrDefault(s => s.ProjectId == projectId)?.RouterSurveyYourSurveyId;
                }

                ra = new RouterAction()
                {
                    RouterContactId = routerContactId,
                    Ip           = ipAddress,
                    RouterHostId = hostId,
                    RouterSurveyPrecisionSampleId = psID,
                    RouterSurveyYourSurveyId      = ysID
                };
                db.RouterActions.Add(ra);
                db.SaveChanges();
            }

            return(ra);
        }