Ejemplo n.º 1
0
        public List <OpportunityType> GetAllOpportunityTypes()
        {
            try
            {
                List <OpportunityType> listOpportunityTypes = new List <OpportunityType>();
                OpportunityType        opportunityType      = null;

                var read = _repositoryConncetion.SearchCommand("GetAllOpportunityTypes", parameters);

                DataTable dataTable = JsonConvert.DeserializeObject <DataTable>(read);

                foreach (DataRow row in dataTable.Rows)
                {
                    opportunityType = new OpportunityType();

                    opportunityType.OpportunityTypeId     = Convert.ToInt32(row["OpportunityTypeId"]);
                    opportunityType.OpportunityName       = row["OpportunityName"].ToString();
                    opportunityType.DateRegister          = Convert.ToDateTime(row["DateRegister"]);
                    opportunityType.OpportunityTypeStatus = Convert.ToBoolean(row["OpportunityTypeStatus"]);

                    listOpportunityTypes.Add(opportunityType);
                }
                return(listOpportunityTypes);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public static void TeachOpportunity(ConceptDef conc, Thing subject, OpportunityType opp)
        {
            if (TutorSystem.AdaptiveTrainingEnabled && !PlayerKnowledgeDatabase.IsComplete(conc))
            {
                float value = 999f;
                switch (opp)
                {
                case OpportunityType.GoodToKnow:
                    value = 60f;
                    break;

                case OpportunityType.Important:
                    value = 80f;
                    break;

                case OpportunityType.Critical:
                    value = 100f;
                    break;

                default:
                    Log.Error("Unknown need", false);
                    break;
                }
                LessonAutoActivator.opportunities[conc] = value;
                if (opp >= OpportunityType.Important || Find.Tutor.learningReadout.ActiveConceptsCount < 4)
                {
                    LessonAutoActivator.TryInitiateLesson(conc);
                }
            }
        }
Ejemplo n.º 3
0
        public async void TestPost()
        {
            using (var client = server.CreateClient().AcceptJson())
            {
                var step        = 1;
                var service     = new OpportunityTypeService();
                var countBefore = service.GetAll().Count();
                var item        = service.GetAll().FirstOrDefault();
                if (item == null)
                {
                    var newItem = new OpportunityType()
                    {
                        Id   = 0,
                        Name = string.Format("OpportunityType {0}", countBefore)
                    };

                    service.Add(item);
                    item = service.GetAll().FirstOrDefault();

                    step = 2;
                }

                var response = await client.PostAsJsonAsync("/api/OpportunityTypes", item);

                var result = await response.Content.ReadAsJsonAsync <OpportunityType>();

                var countAfter = service.GetAll().Count();

                Assert.Equal(countBefore, countAfter - step);
                Assert.Equal((int)response.StatusCode, 201);
            }
        }
Ejemplo n.º 4
0
        public OpportunityType GetOpportunityTypeById(int opportunityTypeId)
        {
            try
            {
                OpportunityType opportunityType = null;

                parameters.Clear();
                parameters.Add("@OpportunityTypeId", opportunityTypeId.ToString());

                var read = _repositoryConncetion.SearchCommand("GetOpportunityTypeById", parameters);

                DataTable dataTable = JsonConvert.DeserializeObject <DataTable>(read);

                foreach (DataRow row in dataTable.Rows)
                {
                    opportunityType = new OpportunityType();

                    opportunityType.OpportunityTypeId     = Convert.ToInt32(row["OpportunityTypeId"]);
                    opportunityType.OpportunityName       = row["OpportunityName"].ToString();
                    opportunityType.DateRegister          = Convert.ToDateTime(row["DateRegister"]);
                    opportunityType.OpportunityTypeStatus = Convert.ToBoolean(row["OpportunityTypeStatus"]);
                }
                return(opportunityType);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
0
        protected TComponents GetBookableOpportunityReference(OpportunityType opportunityType, Uri id)
        {
            var components = IdTemplate.GetOpportunityBookableIdComponents(id);

            if (components.OpportunityType != opportunityType)
            {
                throw new ArgumentOutOfRangeException("Provided opportunityType does not match provided id");
            }
            return(components);
        }
Ejemplo n.º 6
0
 public override int GetHashCode()
 {
     unchecked
     {
         // ReSharper disable NonReadonlyMemberInGetHashCode
         var hashCode = OpportunityType.GetHashCode();
         hashCode = (hashCode * 397) ^ FacilityUseId.GetHashCode();
         hashCode = (hashCode * 397) ^ SlotId.GetHashCode();
         hashCode = (hashCode * 397) ^ OfferId.GetHashCode();
         // ReSharper enable NonReadonlyMemberInGetHashCode
         return(hashCode);
     }
 }
Ejemplo n.º 7
0
        public void DeleteOpportunityType(OpportunityType opportunityType)
        {
            try
            {
                parameters.Add("@OpportunityTypeId", opportunityType.OpportunityTypeId.ToString());

                _repositoryConncetion.SimpleExecuteCommand("DeleteOpportunityType", parameters);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 8
0
        private static void TryActivateTutorial(ConceptDef def, OpportunityType opr)
        {
            if (!triggeredTutorials.Contains(def))
            {
                if (opr >= OpportunityType.Important || IsReady())
                {
                    lastTutorTime = Time.time;

                    LessonAutoActivator.TeachOpportunity(def, opr);
                    triggeredTutorials.Add(def);
                }
            }
        }
 public override int GetHashCode()
 {
     unchecked
     {
         // ReSharper disable NonReadonlyMemberInGetHashCode
         var hashCode = OpportunityType.GetHashCode();
         hashCode = (hashCode * 397) ^ OfferOpportunityType.GetHashCode();
         hashCode = (hashCode * 397) ^ SessionSeriesId.GetHashCode();
         hashCode = (hashCode * 397) ^ ScheduledSessionId.GetHashCode();
         hashCode = (hashCode * 397) ^ OfferId.GetHashCode();
         // ReSharper enable NonReadonlyMemberInGetHashCode
         return(hashCode);
     }
 }
Ejemplo n.º 10
0
        protected override void DeleteTestDataItem(OpportunityType opportunityType, SessionOpportunity sessionOpportunity)
        {
            if (!sessionOpportunity.SessionSeriesId.HasValue || !sessionOpportunity.ScheduledSessionId.HasValue)
            {
                throw new OpenBookingException(new OpenBookingError(), "Invalid Session Id");
            }

            // Note assume that if it's been routed here, it will be possible to cast it to type Event
            switch (opportunityType)
            {
            case OpportunityType.ScheduledSession:
                FakeBookingSystem.Database.DeleteClass(sessionOpportunity.SessionSeriesId.Value, sessionOpportunity.ScheduledSessionId.Value);
                break;
            }
        }
Ejemplo n.º 11
0
        public void UpdateOpportunityType(OpportunityType opportunityType)
        {
            try
            {
                parameters.Add("@OpportunityName", opportunityType.OpportunityName);
                parameters.Add("@DateRegister", opportunityType.DateRegister.ToString());
                parameters.Add("@OpportunityTypeStatus", opportunityType.OpportunityTypeStatus.ToString());
                parameters.Add("@OpportunityTypeId", opportunityType.OpportunityTypeId.ToString());

                _repositoryConncetion.SimpleExecuteCommand("UpdateOpportunityType", parameters);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 12
0
        public int InsertOpportunityType(OpportunityType opportunityType)
        {
            try
            {
                parameters.Add("@OpportunityName", opportunityType.OpportunityName);
                parameters.Add("@DateRegister", opportunityType.DateRegister.ToString());
                parameters.Add("@OpportunityTypeStatus", opportunityType.OpportunityTypeStatus.ToString());

                int opportunityTypeId = _repositoryConncetion.InsertCommand("InsertOpportunityType", parameters);

                return(opportunityTypeId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 13
0
        protected override SessionOpportunity CreateTestDataItem(OpportunityType opportunityType, Event @event)
        {
            // Note assume that if it's been routed here, it will be possible to cast it to type Event
            switch (opportunityType)
            {
            case OpportunityType.ScheduledSession:
                var session    = (ScheduledSession)@event;
                var superEvent = (SessionSeries)session.SuperEvent.GetClass <Event>();
                var(classId, occurrenceId) = FakeBookingSystem.Database.AddClass(superEvent.Name, superEvent.Offers?.FirstOrDefault()?.Price, session.StartDate.GetPrimative <DateTimeOffset>() ?? default, session.EndDate.GetPrimative <DateTimeOffset>() ?? default, session.MaximumAttendeeCapacity.Value);
                return(new SessionOpportunity {
                    OpportunityType = opportunityType,
                    SessionSeriesId = classId,
                    ScheduledSessionId = occurrenceId
                });

            default:
                throw new OpenBookingException(new OpenBookingError(), "Opportunity Type not supported");
            }
        }
 public Uri RenderOfferId(OpportunityType opportunityType, TBookableIdComponents components)
 {
     if (opportunityType == OpportunityIdConfiguration.OpportunityType)
     {
         return(RenderId(1, components, nameof(RenderOfferId), "offerUriTemplate"));
     }
     else if (opportunityType == ParentIdConfiguration?.OpportunityType)
     {
         return(RenderId(3, components, nameof(RenderOfferId), "parentOfferUriTemplate"));
     }
     else if (opportunityType == GrandparentIdConfiguration?.OpportunityType)
     {
         return(RenderId(5, components, nameof(RenderOfferId), "parentOfferUriTemplate"));
     }
     else
     {
         throw new ArgumentOutOfRangeException(nameof(opportunityType), "OpportunityType was not found within this template");
     }
 }
Ejemplo n.º 15
0
 public ActionResult AddCampaignSource(OpportunityType opportunityType, string campaignName, CampaignStatus campaignStatus, DateTime startDate, DateTime finishDate, decimal expectedRevenue)
 {
     try
     {
         var campaign = new Campaign();
         campaign.Name            = campaignName;
         campaign.CampaignStatus  = campaignStatus;
         campaign.OpportunityType = opportunityType;
         campaign.ExpectedRevenue = expectedRevenue;
         campaign.EndDate         = finishDate;
         campaign.StartDate       = startDate;
         campaignService.Insert(campaign);
         return(Json(true));
     }
     catch (Exception ex)
     {
         return(Json(false));
     }
 }
Ejemplo n.º 16
0
        public void TestAdd()
        {
            ConfigurationHelper.Ensure();

            var service = new OpportunityTypeService();

            var countBefore = service.GetAll().Count();

            var newItem = new OpportunityType()
            {
                Id   = 0,
                Name = string.Format("OpportunityType {0}", countBefore)
            };

            service.Add(newItem);

            var countAfter = service.GetAll().Count();

            Assert.Equal(countBefore, countAfter - 1);
        }
Ejemplo n.º 17
0
        public static Event RenderOpportunityWithOnlyId(OpportunityType opportunityType, Uri id)
        {
            // TODO: Create an extra prop in DatasetSite lib so that we don't need to parse the URL here
            switch (OpportunityTypes.Configurations[opportunityType].SameAs.AbsolutePath.Trim('/'))
            {
            case nameof(Event):
                return(new Event {
                    Id = id
                });

            case nameof(ScheduledSession):
                return(new ScheduledSession {
                    Id = id
                });

            case nameof(HeadlineEvent):
                return(new HeadlineEvent {
                    Id = id
                });

            case nameof(Slot):
                return(new Slot {
                    Id = id
                });

            case nameof(CourseInstance):
                return(new CourseInstance {
                    Id = id
                });

            case nameof(OnDemandEvent):
                return(new OnDemandEvent {
                    Id = id
                });

            default:
                return(null);
            }
        }
        public Uri RenderOpportunityId(OpportunityType opportunityType, TBookableIdComponents components)
        {
            if (components == null)
            {
                throw new ArgumentNullException(nameof(components));
            }

            if (opportunityType == OpportunityIdConfiguration.OpportunityType)
            {
                return(RenderId(0, components, nameof(RenderOpportunityId), "opportunityUriTemplate"));
            }
            else if (opportunityType == ParentIdConfiguration?.OpportunityType)
            {
                return(RenderId(2, components, nameof(RenderOpportunityId), "parentOpportunityUriTemplate"));
            }
            else if (opportunityType == GrandparentIdConfiguration?.OpportunityType)
            {
                return(RenderId(4, components, nameof(RenderOpportunityId), "parentOpportunityUriTemplate"));
            }
            else
            {
                throw new ArgumentOutOfRangeException(nameof(opportunityType), "OpportunityType was not found within this template. Please check it is appropriate for this feed or OrderItem.");
            }
        }
Ejemplo n.º 19
0
 public static void TeachOpportunity(ConceptDef conc, OpportunityType opp)
 {
     TeachOpportunity(conc, null, opp);
 }
Ejemplo n.º 20
0
 public static void TeachOpportunity(ConceptDef conc, OpportunityType opp)
 {
     LessonAutoActivator.TeachOpportunity(conc, null, opp);
 }
Ejemplo n.º 21
0
 public static bool RequiresOccurrences(OpportunityType opportunityType)
 {
     return(OpportunityTypesRequiringOccurrences.Contains(opportunityType));
 }
 protected abstract void DeleteTestDataItem(OpportunityType opportunityType, Uri id);
        public void DeleteTestDataItemEvent(OpportunityType opportunityType, Uri id)
        {
            var components = GetBookableOpportunityReference(opportunityType, id);

            DeleteTestDataItem(opportunityType, components);
        }
        public Event CreateTestDataItemEvent(OpportunityType opportunityType, Event @event)
        {
            var components = CreateTestDataItem(opportunityType, @event);

            return(OrderCalculations.RenderOpportunityWithOnlyId(RenderOpportunityJsonLdType(components), RenderOpportunityId(components)));
        }
 protected abstract void DeleteTestDataItem(OpportunityType opportunityType, TComponents components);
 protected abstract TComponents CreateTestDataItem(OpportunityType opportunityType, Event @event);
 private List <Opportunity> GetFilteredOpportunities(IEnumerable <Opportunity> opportunities, OpportunityType opportunityType)
 {
     return(opportunities
            .Where(o => o.OpportunityType == opportunityType)
            .ToList());
 }
Ejemplo n.º 28
0
 protected abstract Task <Event> InsertTestOpportunity(string testDatasetIdentifier, OpportunityType opportunityType, TestOpportunityCriteriaEnumeration criteria, TestOpenBookingFlowEnumeration openBookingFlow, SellerIdComponents seller);
Ejemplo n.º 29
0
 protected Uri RenderOfferId(OpportunityType opportunityType, TComponents components)
 {
     return(IdTemplate.RenderOfferId(opportunityType, components));
 }
 protected abstract Event CreateTestDataItem(OpportunityType opportunityType, Event @event);