Пример #1
0
 public static List <Person> GetEmployeesByID(List <String> Ids)
 {
     using (var db = new PartyContext())
     {
         return(db.employees.Where(x => Ids.Contains(x.PersonId.ToString())).ToList());
     }
 }
Пример #2
0
        public static List <Party> FilterParty(int index, string text)
        {
            text = text.ToLower();
            using (var db = new PartyContext())
            {
                switch (index)
                {
                case 0:
                    return(db.parties.Where(t => t.Name.ToLower().Contains(text) || t.Adress.ToLower().Contains(text) || t.City.ToLower().Contains(text) || t.Email.ToLower().Contains(text) || t.Phone.ToLower().Contains(text) || IsContained(GetOrgasByID(t.OrgaIDs), FilterOrga(text)) || IsContained(GetEmployeesByIDFromStand(t.StandsIDs), FilterPerson(text))).ToList());

                case 1:
                    return(db.parties.Where(t => t.Name.ToLower().Contains(text)).ToList());

                case 2:
                    return(db.parties.Where(t => t.Adress.ToLower().Contains(text) || t.City.ToLower().Contains(text)).ToList());

                case 3:
                    return(db.parties.Where(i => IsContained(GetOrgasByID(i.OrgaIDs), FilterOrga(text))).ToList());

                case 4:
                    return(db.parties.Where(i => IsContained(GetEmployeesByIDFromStand(i.StandsIDs), FilterPerson(text))).ToList());

                default:
                    return(null);
                }
            }
        }
Пример #3
0
 public static List <Skill> GetSkillsByID(List <String> Ids)
 {
     using (var db = new PartyContext())
     {
         return(db.skills.Where(x => Ids.Contains(x.ToolId.ToString())).ToList());
     }
 }
Пример #4
0
 public static List <Party> SearchPartiesByName(Party party)
 {
     using (var db = new PartyContext())
     {
         return(db.parties.Where(x => x.Name == party.Name).OrderBy(x => x.Date).ToList());
     }
 }
Пример #5
0
 public static void DeleteStands(Party partyTmp, List <string> Stands)
 {
     using (var db = new PartyContext())
     {
         Party party = db.parties.Find(partyTmp.PartyId);
         if (party != null)
         {
             List <string> realStands   = party.StandsIDs;
             List <string> removedstand = Stands.Except(realStands).ToList();
             foreach (string standId in removedstand)
             {
                 var stand = db.stands.Find(Convert.ToInt32(standId));
                 db.Entry(stand).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
             }
         }
         else
         {
             if (partyTmp.StandsIDs != null)
             {
                 foreach (string standId in partyTmp.StandsIDs)
                 {
                     var stand = db.stands.Find(Convert.ToInt32(standId));
                     db.Entry(stand).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
                 }
             }
         }
         db.SaveChanges();
     }
 }
Пример #6
0
        public static void CheckParties()
        {
            using (var db = new PartyContext())
            {
                Debug.WriteLine("fff");
                foreach (Party party in db.parties)
                {
                    if (party.ToDate.CompareTo(DateTime.Today) < 0 && !party.AlreadyDone)
                    {
                        party.AlreadyDone = true;
                        var partyDb = db.parties.Find(party.PartyId);
                        db.Entry(partyDb).CurrentValues.SetValues(party);

                        Party tmp      = new Party();
                        Party newParty = Utilities.CloneJson <Party>(party);
                        newParty.PartyId         = tmp.PartyId;
                        newParty.StandsAsStrings = null;
                        newParty.FilesAsStrings  = null;
                        newParty.Accepted        = true;
                        newParty.AlreadyDone     = false;
                        newParty.ToDate          = newParty.ToDate.AddMonths(party.Frequency);
                        newParty.Date            = newParty.Date.AddMonths(party.Frequency);
                        db.parties.Add(newParty);
                    }
                }
                db.SaveChanges();
            }
        }
Пример #7
0
 public static List <Person> FilterPerson(string text)
 {
     using (var db = new PartyContext())
     {
         return(db.employees.Where(t => t.Name.ToLower().Contains(text.ToLower()) || t.Surname.ToLower().Contains(text.ToLower()) || t.City.ToLower().Contains(text.ToLower())).ToList());
     }
 }
Пример #8
0
        public static int CountTool(Tool tool, Party party, Stand currentStand)
        {
            int counter = 0;

            using (var db = new PartyContext())
            {
                var parties = db.parties.Where(x => (party.Date.CompareTo(x.ToDate) <= 0 && x.Date.CompareTo(party.Date) < 0) || (party.ToDate.CompareTo(x.Date) >= 0 && x.ToDate.CompareTo(party.ToDate) >= 0) || (party.Date.CompareTo(x.Date) <= 0 && party.ToDate.CompareTo(x.ToDate) > 0)).ToList <Party>();
                foreach (Party tmp in parties)
                {
                    foreach (Stand stand in GetStandsByID(tmp.StandsIDs))
                    {
                        if (stand.StandId != currentStand.StandId)
                        {
                            List <string> toolsIds = stand.ToolsAsStrings.Split(',').ToList();
                            counter += toolsIds.Where(x => x.Equals(tool.ToolId.ToString())).Count();
                        }
                    }
                }
                if (currentStand.ToolsAsStrings != null)
                {
                    Debug.WriteLine(currentStand.ToolsAsStrings);
                    List <string> tmp2 = currentStand.ToolsAsStrings.Split(',').ToList();
                    counter += tmp2.Where(x => x.Equals(tool.ToolId.ToString())).Count();
                }
            }
            return(counter);
        }
Пример #9
0
 public static List <File> GetFilesByID(List <String> Ids)
 {
     using (var db = new PartyContext())
     {
         return(db.files.Where(x => Ids.Contains(x.FileId.ToString())).ToList());
     }
 }
Пример #10
0
        public static List <Party> GetToBeNotifiedParties()
        {
            List <Party> parties   = new List <Party>();
            List <int>   tmpMonths = new List <int> {
                1, 3, 6
            };

            using (var db = new PartyContext())
            {
                foreach (Party party in db.parties.ToList())
                {
                    if (party.MonthToGo >= 0)
                    {
                        int result  = DateTime.Today.AddMonths(tmpMonths[party.WriteMonthly]).CompareTo(party.Date);
                        int result2 = party.Lastwrote.AddMonths(tmpMonths[party.WriteMonthly]).CompareTo(party.Date);
                        Debug.WriteLine(result);
                        Debug.WriteLine(result2);
                        if (result >= 0 && result2 < 0)
                        {
                            parties.Add(party);
                        }
                    }
                }
            }
            return(parties);
        }
Пример #11
0
 public static List <Organisateur> GetOrgasByID(List <String> Ids)
 {
     using (var db = new PartyContext())
     {
         return(db.organisateurs.Where(x => Ids.Contains(x.OrganisateurId.ToString())).ToList());
     }
 }
Пример #12
0
 public static List <Stand> GetStandsByID(List <String> Ids)
 {
     using (var db = new PartyContext())
     {
         return(db.stands.Where(x => Ids.Contains(x.StandId.ToString())).ToList());
     }
 }
Пример #13
0
 public static void DeleteToolEntry(Tool element)
 {
     using (var db = new PartyContext())
     {
         db.Entry(element).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
         db.SaveChanges();
     }
 }
Пример #14
0
 public static List <Organisateur> FilterOrga(string text)
 {
     text = text.ToLower();
     using (var db = new PartyContext())
     {
         return(db.organisateurs.Where(t => t.Name.ToLower().Contains(text) || t.Surname.ToLower().Contains(text)).ToList());
     }
 }
Пример #15
0
 public static void DeletePartyEntry(Party element)
 {
     RemoveStands(element);
     using (var db = new PartyContext())
     {
         db.Entry(element).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
         db.SaveChanges();
     }
 }
Пример #16
0
 public static void RemoveStands(Party party)
 {
     using (var db = new PartyContext())
     {
         foreach (Stand stand in GetStandsByID(party.StandsIDs))
         {
             db.Entry(stand).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
         }
         db.SaveChanges();
     }
 }
Пример #17
0
        public static List <Person> GetEmployeesByIDFromStand(List <String> Ids)
        {
            List <Person> result = new List <Person>();
            List <Stand>  stands = GetStandsByID(Ids);

            using (var db = new PartyContext())
            {
                foreach (Stand stand in stands)
                {
                    result.Concat(db.employees.Where(x => stand.EmployeesIDs.Contains(x.PersonId.ToString())).ToList());
                }
                return(result);
            }
        }
Пример #18
0
        public static List <Party> FindPartyByDate(DateTimeOffset date)
        {
            List <Party> returnList = new List <Party>();

            using (var db = new PartyContext())
            {
                foreach (Party tmp in db.parties.ToList())
                {
                    if (date.Date.CompareTo(tmp.Date.Date) >= 0 && date.Date.CompareTo(tmp.ToDate.Date) <= 0)
                    {
                        returnList.Add(tmp);
                    }
                }
            }
            return(returnList);
        }
Пример #19
0
 public static List <Tool> GetToolsByID(List <string> Ids)
 {
     using (var db = new PartyContext())
     {
         List <Tool> result = new List <Tool>();
         var         ids    = db.tools.Select(i => i.ToolId.ToString());
         if (Ids != null)
         {
             foreach (string id in Ids)
             {
                 if (!id.Equals(""))
                 {
                     result.Add(db.tools.Find(Convert.ToInt32(id)));
                 }
             }
         }
         return(result);
     }
 }
 //creating constructor, dependency injection
 public PartyEventController(PartyContext partyContext)
 {
     //initialization
     _partyContext = partyContext;
 }
 public GuestResponseRepo(PartyContext context)
 {
     _context = context;
 }
Пример #22
0
        public EventQuery()
        {
            var db = new PartyContext();

            Field <ListGraphType <EventType> >(
                "event",
                arguments: new QueryArguments(new QueryArgument <StringGraphType> {
                Name = "email"
            },
                                              new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                resolve: context =>
            {
                if (context.Arguments.ContainsKey("id"))
                {
                    var id = (int)context.Arguments["id"];

                    return(db.Events
                           .Include(e => e.Contributions).Where(e => e.EventId == id)
                           .Include(e => e.Owner)
                           .Include(e => e.Schedules)
                           .Include(p => p.EventGuests)
                           .ThenInclude(p => p.Guest));
                }

                var email = (string)context.Arguments["email"];
                return(db.Events
                       .Include(e => e.Owner)
                       .Include(e => e.Schedules)
                       .Include(e => e.Contributions).Where(e => e.Owner.Email == email)
                       .Include(p => p.EventGuests)
                       .ThenInclude(p => p.Guest));
            }
                );

            Field <ListGraphType <EventType> >(
                "events",
                resolve: context => db.Events
                .Include(e => e.Owner)
                .Include(e => e.Schedules)
                .Include(e => e.Contributions)
                .Include(p => p.EventGuests)
                .ThenInclude(p => p.Guest)
                .ToList()
                );

            Field <ContactType>(
                "contact",
                arguments: new QueryArguments(new QueryArgument <StringGraphType> {
                Name = "email"
            }),
                resolve: context =>
            {
                var objectId = (string)context.Arguments["email"];
                return(db.Contacts
                       .Include(p => p.OwnedEvents)
                       .ThenInclude(t => t.Contributions)
                       .Include(t => t.OwnedEvents)
                       .ThenInclude(p => p.Schedules)
                       .Include(p => p.GuestEvents)
                       .ThenInclude(p => p.Event)
                       .FirstOrDefault(c => c.Email == objectId));
            }
                );
        }
Пример #23
0
 public GiftRepo(PartyContext context)
 {
     _context = context;
 }
Пример #24
0
        // Remember to add the OdinDrawer to your custom drawer classes, or they will not be found by Odin.
        protected override void DrawPropertyGroupLayout(InspectorProperty property, PartyGroupAttribute attribute, GUIContent label)
        {
            GUILayout.Space(8f);

            // Changes the current GUI transform matrix, to make the inspector party.
            if (Event.current.rawType != EventType.Layout)
            {
                Vector3   offset = property.LastDrawnValueRect.position + new Vector2(property.LastDrawnValueRect.width, property.LastDrawnValueRect.height) * 0.5f;
                Matrix4x4 matrix =
                    Matrix4x4.TRS(offset, Quaternion.identity, Vector3.one) *
                    Matrix4x4.TRS(Vector3.zero, Quaternion.AngleAxis(Mathf.Sin((float)EditorApplication.timeSinceStartup * attribute.Speed) * attribute.Range, Vector3.forward), Vector3.one * (1f + MathUtilities.BounceEaseInFastOut(Mathf.Sin((float)UnityEditor.EditorApplication.timeSinceStartup * 2f)) * 0.1f)) *
                    Matrix4x4.TRS(-offset + new Vector3(Mathf.Sin((float)EditorApplication.timeSinceStartup * 2f), 0f, 0f) * 100f, Quaternion.identity, Vector3.one) *
                    GUI.matrix;
                GUIHelper.PushMatrix(matrix);
            }

            // Changes the party color.
            if (Event.current.rawType == EventType.Repaint)
            {
                var contextBuffer = property.Context.Get <PartyContext>(this, "Color", (PartyContext)null);
                var context       = contextBuffer.Value;
                if (context == null)
                {
                    context = new PartyContext()
                    {
                        Start  = UnityEngine.Random.ColorHSV(0f, 1f, 0.8f, 1f, 1f, 1f),
                        Target = UnityEngine.Random.ColorHSV(0f, 1f, 0.8f, 1f, 1f, 1f),
                    };
                    contextBuffer.Value = context;
                }

                float t = MathUtilities.Bounce(Mathf.Sin((float)EditorApplication.timeSinceStartup * 2f));
                if (t <= 0f)
                {
                    context.Start  = context.Target;
                    context.Target = UnityEngine.Random.ColorHSV(0f, 1f, 0.8f, 1f, 1f, 1f);
                }

                GUIHelper.PushColor(Color.Lerp(context.Start, context.Target, t));
            }

            // Draws all the child properties of the group.
            SirenixEditorGUI.BeginBox();
            for (int i = 0; i < property.Children.Count; i++)
            {
                property.Children[i].Draw();
            }
            SirenixEditorGUI.EndBox();

            // Revert changes to GUI color and matrix.
            if (Event.current.rawType == EventType.Repaint)
            {
                GUIHelper.PopColor();
            }
            if (Event.current.rawType != EventType.Layout)
            {
                GUIHelper.PopMatrix();
            }

            // Request a repaint for fluid motion.
            GUIHelper.RequestRepaint();
            GUILayout.Space(8f);
        }
        public EventMutation()
        {
            var db = new PartyContext();

            Field <EventType>(
                "createEvent",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <EventInputType> > {
                Name = "event"
            },
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "email"
            }
                    ),
                resolve: context =>
            {
                var ev    = context.GetArgument <Event>("event");
                var email = context.GetArgument <string>("email");
                ev.Owner  = db.Contacts.FirstOrDefault(c => c.Email == email);
                db.Events.Add(ev);
                db.SaveChanges();
                return(ev);
            });

            Field <ListGraphType <ContrubutionType> >(
                "createContributions",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ListGraphType <ContributionInputType> > > {
                Name = "contributions"
            }
                    ),
                resolve: context =>
            {
                var contributions = context.GetArgument <List <Contribution> >("contributions");
                db.Contributions.AddRange(contributions);
                db.SaveChanges();
                return(contributions);
            });

            Field <ContactType>(
                "createContact",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ContactInputType> > {
                Name = "contact"
            }
                    ),
                resolve: context =>
            {
                var ct = context.GetArgument <Contact>("contact");
                db.Contacts.Add(ct);
                db.SaveChanges();
                return(ct);
            });

            Field <ListGraphType <EventGuestType> >(
                "createEventGuests",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ListGraphType <EventGuestInputType> > > {
                Name = "eventGuest"
            }
                    ),
                resolve: context =>
            {
                var guests = context.GetArgument <List <EventGuest> >("eventGuest");
                db.EventGuests.AddRange(guests);
                db.SaveChanges();
                return(guests);
            });
        }
Пример #26
0
 private Party(PartyContext partyContext)
 {
     context = partyContext;
 }
Пример #27
0
 public EFPartyService(PartyContext context)
 {
     _context = context;
 }