Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(Guid eventId)
        {
            var cancellationToken = GetCancellationToken();
            var familyEvent       = await _readmodel.Load(eventId, cancellationToken);

            var gallery = await _galleryReadRepository.FindAllByFamilyEvent(familyEvent.ID, cancellationToken);

            var imageReference = (await _imageReferenceReadRepository.LoadByGallery(gallery.FirstOrDefault(g => g.DefaultFamilyEventGallery).ID, cancellationToken)).FirstOrDefault(ir => ir.DefaultGalleryImage);
            var fe             = imageReference == null?FamilyEvent.Map(familyEvent) : FamilyEvent.MapWithImageReference(familyEvent, imageReference.ID, gallery.FirstOrDefault(g => g.DefaultFamilyEventGallery).ID, imageReference.Title);

            return(View("EditEvent", fe));
        }
Ejemplo n.º 2
0
    public int StartFamily(int treePersonIndex, int treePersonSpouceIndex, string year)
    {
        Family myFamily    = null;
        int    familyIndex = -1;

        FamilyEvent marriageevent = MakeMarriageEvent(treePersonIndex, treePersonSpouceIndex, year ?? "");

        if (marriageevent != null)
        {
            myFamily = new Family(marriageevent.Generation, marriageevent.BridePersonIndex,
                                  marriageevent.GroompersonIndex, marriageevent.Date);
            familyIndex = addToAllFamilies(myFamily);
            marriageevent.FamilyIndex = familyIndex;
            myPeople.allPeople[marriageevent.BridePersonIndex].MarriedFamilyIndex = familyIndex;
            myPeople.allPeople[marriageevent.GroompersonIndex].MarriedFamilyIndex = familyIndex;
            myPeople.allPeople[marriageevent.BridePersonIndex].AddEvent(marriageevent);
            myPeople.allPeople[marriageevent.GroompersonIndex].AddEvent(marriageevent);
        }

        return(familyIndex);
    }
Ejemplo n.º 3
0
    public FamilyEvent MakeMarriageEvent(int treePersonIndex, int treePersonSpouceIndex, string year)
    {
        FamilyEvent retMarriageEvent = null;

        // Okay, who is the Man, and who is the woman, we need to know
        // Assume this for now
        var boyPersonIndex  = treePersonIndex;
        var girlPersonIndex = treePersonSpouceIndex;

        if (myPeople.allPeople[treePersonIndex].Sex == TreePerson.PersonSex.Female ||
            myPeople.allPeople[treePersonSpouceIndex].Sex == TreePerson.PersonSex.Male)
        {
            boyPersonIndex  = treePersonSpouceIndex;
            girlPersonIndex = treePersonIndex;
        }

        if (girlPersonIndex != 0)
        {
            retMarriageEvent = new FamilyEvent(myPeople, allFamilies, FamilyEvent.FamilyEventType.Marriage, year, girlPersonIndex,
                                               boyPersonIndex);
        }
        return(retMarriageEvent);
    }
Ejemplo n.º 4
0
    public FamilyEvent MakeMarriageEvent(int treePersonIndex, int treePersonSpouceIndex, string year)
    {
        FamilyEvent retMarriageEvent = null;

        // Okay, who is the Man, and who is the woman, we need to know
        // Assume this for now
        var boyPersonIndex = treePersonIndex;
        var girlPersonIndex = treePersonSpouceIndex;

        if (myPeople.allPeople[treePersonIndex].Sex == TreePerson.PersonSex.Female ||
            myPeople.allPeople[treePersonSpouceIndex].Sex == TreePerson.PersonSex.Male)
        {
            boyPersonIndex = treePersonSpouceIndex;
            girlPersonIndex = treePersonIndex;
        }

        if (girlPersonIndex != 0)
        {
            retMarriageEvent = new FamilyEvent(myPeople, allFamilies, FamilyEvent.FamilyEventType.Marriage, year, girlPersonIndex,
                boyPersonIndex);
        }
        return retMarriageEvent;
    }
Ejemplo n.º 5
0
 public void AddEvent(FamilyEvent newEvent)
 {
     myEvents.Add(newEvent);
 }
        public async Task <IActionResult> CreateEvent([FromBody] JsonEventModel ev)
        {
            if (ev == null)
            {
                return(NotFound());
            }
            else
            {
                var Venue       = _context.Venue.SingleOrDefault(v => v.ApplicationUser.Id == userManager.GetUserId(HttpContext.User));
                var FamilyEvent = _context.FamilyEvent.SingleOrDefault(f => f.Name == ev.Name);
                int days        = 0;
                if (Venue == null)
                {
                    return(NotFound());
                }
                else if (FamilyEvent == null)
                {
                    FamilyEvent familyEvent = new FamilyEvent
                    {
                        Name = ev.Name
                    };
                    _context.Add(familyEvent);
                    await _context.SaveChangesAsync();

                    FamilyEvent = _context.FamilyEvent.SingleOrDefault(f => f.Name == ev.Name);
                }
                int everyNum = 0;
                switch (ev.Repeat.SelectRepeat)
                {
                case "Day":
                    if (ev.Repeat.AfterNumTimes != "")
                    {
                        for (int i = 0; i < int.Parse(ev.Repeat.AfterNumTimes); i++)
                        {
                            Event nEvent = new Event
                            {
                                Name          = ev.Name,
                                StartDateTime = ev.StartDateTime.AddDays(everyNum).ToLocalTime(),
                                EndTime       = ev.EndTime.AddDays(everyNum).ToLocalTime(),
                                EventTypeId   = int.Parse(ev.EventTypeId),
                                VenueId       = Venue.Id,
                                FamilyEventId = FamilyEvent.Id
                            };
                            everyNum += int.Parse(ev.Repeat.NumOfRepeat);
                            _context.Add(nEvent);
                        }
                    }
                    else
                    {
                        while (ev.Repeat.UntilDate > ev.StartDateTime.AddDays(everyNum))
                        {
                            Event nEvent = new Event
                            {
                                Name          = ev.Name,
                                StartDateTime = ev.StartDateTime.AddDays(everyNum).ToLocalTime(),
                                EndTime       = ev.EndTime.AddDays(everyNum).ToLocalTime(),
                                EventTypeId   = int.Parse(ev.EventTypeId),
                                VenueId       = Venue.Id,
                                FamilyEventId = FamilyEvent.Id
                            };
                            everyNum += int.Parse(ev.Repeat.NumOfRepeat);
                            _context.Add(nEvent);
                        }
                    }
                    break;

                case "Week":

                    if (ev.Repeat.AfterNumTimes != "")
                    {
                        for (int i = 0; i < int.Parse(ev.Repeat.AfterNumTimes) * 7; i++)
                        {
                            if (CorrectDay(ev, i, everyNum) == true)
                            {
                                Event nEvent = new Event
                                {
                                    Name          = ev.Name,
                                    StartDateTime = ev.StartDateTime.AddDays(i + (everyNum * 7)).ToLocalTime(),
                                    EndTime       = ev.EndTime.AddDays(i + (everyNum * 7)).ToLocalTime(),
                                    EventTypeId   = int.Parse(ev.EventTypeId),
                                    VenueId       = Venue.Id,
                                    FamilyEventId = FamilyEvent.Id
                                };

                                _context.Add(nEvent);
                            }
                            if (i + 1 >= 7)
                            {
                                if ((i + 1) % 7 == 0)
                                {
                                    everyNum += (int.Parse(ev.Repeat.NumOfRepeat) - 1);
                                }
                            }
                        }
                    }
                    else
                    {
                        int i = 0;
                        while (ev.Repeat.UntilDate > ev.StartDateTime.AddDays(i))
                        {
                            if (CorrectDay(ev, i, everyNum))
                            {
                                Event nEvent = new Event
                                {
                                    Name          = ev.Name,
                                    StartDateTime = ev.StartDateTime.AddDays(i + (everyNum * 7)).ToLocalTime(),
                                    EndTime       = ev.EndTime.AddDays(i + (everyNum * 7)).ToLocalTime(),
                                    EventTypeId   = int.Parse(ev.EventTypeId),
                                    VenueId       = Venue.Id,
                                    FamilyEventId = FamilyEvent.Id
                                };

                                _context.Add(nEvent);
                            }
                            if (i + 1 >= 7)
                            {
                                if ((i + 1) % 7 == 0)
                                {
                                    everyNum += (int.Parse(ev.Repeat.NumOfRepeat) - 1);
                                }
                            }
                            i++;
                        }
                    }
                    break;

                case "Month":
                    if (ev.Repeat.AfterNumTimes != "")
                    {
                        for (int i = 0; i < int.Parse(ev.Repeat.AfterNumTimes); i++)
                        {
                            Event nEvent = new Event
                            {
                                Name          = ev.Name,
                                StartDateTime = ev.StartDateTime.AddMonths(everyNum).ToLocalTime(),
                                EndTime       = ev.EndTime.AddMonths(everyNum).ToLocalTime(),
                                EventTypeId   = int.Parse(ev.EventTypeId),
                                VenueId       = Venue.Id,
                                FamilyEventId = FamilyEvent.Id
                            };
                            everyNum += int.Parse(ev.Repeat.NumOfRepeat);
                            _context.Add(nEvent);
                        }
                    }
                    else
                    {
                        while (ev.Repeat.UntilDate > ev.StartDateTime.AddMonths(everyNum))
                        {
                            Event nEvent = new Event
                            {
                                Name          = ev.Name,
                                StartDateTime = ev.StartDateTime.AddMonths(everyNum).ToLocalTime(),
                                EndTime       = ev.EndTime.AddMonths(everyNum).ToLocalTime(),
                                EventTypeId   = int.Parse(ev.EventTypeId),
                                VenueId       = Venue.Id,
                                FamilyEventId = FamilyEvent.Id
                            };
                            everyNum += int.Parse(ev.Repeat.NumOfRepeat);
                            _context.Add(nEvent);
                        }
                    }
                    break;
                }
            }
            await _context.SaveChangesAsync();

            Response.StatusCode = (int)HttpStatusCode.OK;
            return(Json(Response.StatusCode));
        }
Ejemplo n.º 7
0
 public void AddEvent(FamilyEvent newEvent)
 {
     myEvents.Add(newEvent);
 }