Exemple #1
0
        public static void AddFeedback(Feedback NewFeedback)
        {
            WorkSpace workSpace = DBManager.GetWorkSpaceCollection()
                                  .Find(WS => WS.ID == NewFeedback.WorkSpaceID).FirstOrDefault();
            var filter = Builders <WorkSpace> .Filter.Eq("ID", workSpace.ID);

            //If  workspace not contain any feedback we creatiing new List of Feedback
            if (workSpace.Feedback == null)
            {
                NewFeedback.ID = ObjectId.GenerateNewId();// creating new feedback ID
                List <Feedback> newList = new List <Feedback>();
                newList.Add(NewFeedback);
                //Update feedback List in the Workspace obj
                var update = Builders <WorkSpace> .Update.Set("Feedback", newList);

                DBManager.EditWorkSpace(filter, update);
            }
            //if the feedback list wasn't empty we will push into the list the new feedback and update workspace in DB
            else
            {
                NewFeedback.ID = ObjectId.GenerateNewId();// creating new feedback ID
                workSpace.Feedback.Add(NewFeedback);
                var update = Builders <WorkSpace> .Update.Set("Feedback", workSpace.Feedback);

                DBManager.EditWorkSpace(filter, update);
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stand"></param>
        public static void AddStand(Stand stand)
        {
            WorkSpace workSpace = DBManager.GetWorkSpaceCollection()
                                  .Find(WS => WS.ID == stand.WorkSpaceID).FirstOrDefault();
            var filter = Builders <WorkSpace> .Filter.Eq("ID", workSpace.ID);

            //If the stand list is empty in the current WorkSpace we create new Stand List
            if (workSpace.Stands == null)
            {
                /* stand.ID = ObjectId.GenerateNewId();*/// creating new stand ID
                List <Stand> newList = new List <Stand>();
                stand.Position = 0;
                for (int i = 0; i < stand.Quantity; i++)
                {
                    stand.ID = ObjectId.GenerateNewId(); /*creating new stand ID*/
                    newList.Add(stand);
                }
                //Update Stand List in the Workspace obj
                var update = Builders <WorkSpace> .Update
                             .Set("Stands", newList);

                DBManager.EditWorkSpace(filter, update);
            }
            //if Stand list was not empty then we just add into it the new stand
            else
            {
                var StandsCounter = workSpace.Stands.Count();
                stand.Position = StandsCounter;
                for (int i = 0; i < stand.Quantity; i++) // The company selects the number of positions(Quantity) it has. And in this loop we put each position separately
                {
                    stand.ID = ObjectId.GenerateNewId(); /*creating new stand ID*/
                    workSpace.Stands.Add(stand);

                    var update = Builders <WorkSpace> .Update
                                 .Set("Stands", workSpace.Stands);

                    DBManager.EditWorkSpace(filter, update);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// This method will recive a Workspace
        /// First we check if ws already exits and then: insert the new ws into DB
        /// Secound insert into Company obj the workspaceID
        /// </summary>
        /// <param name="workSpace"></param>
        /// <returns>List<WorkSpace></returns>
        public static IEnumerable <WorkSpace> AddWorkSpace(WorkSpace workSpace)
        {
            List <WorkSpace> WorkSpaceDB = new List <WorkSpace>();

            try
            {
                var WS_ToCheck = GetWorkSpaceByEmail(workSpace.Email);
                if (WS_ToCheck == null)
                {
                    DBManager.GetWorkSpaceCollection().InsertOne(workSpace);
                    WorkSpace inserted = GetWorkSpaceByEmail(workSpace.Email);
                    WorkSpaceDB.Add(inserted);
                    DBManager.UpdateComapnySpaces(inserted);
                    return(WorkSpaceDB);
                }
            }
            catch
            {
                //return exception to user that workspace already exits in the sys
            }
            return(WorkSpaceDB);
        }