public static bool Update(int id, string dateInitiated, string rate1, string rate2, string rate3, string textGoal)
        {
            SinaicspDataModelContainer _context = new Sinaicsp_API.SinaicspDataModelContainer();
            CSPGoalCatalog             itemById = _context.CSPGoalCatalogs.FirstOrDefault(a => a.Id == id);
            CSPGoalCatalog             _item    = itemById;

            _item.DateInitiated = dateInitiated;
            _item.Rate1         = rate1;
            _item.Rate2         = rate2;
            _item.Rate3         = rate3;
            _item.TextGoal      = textGoal;
            _context.SaveChanges();
            return(true);
        }
        public static void SoftDelete(int id)
        {
            SinaicspDataModelContainer _context = new Sinaicsp_API.SinaicspDataModelContainer();
            CSPGoalCatalog             _item    = _context.CSPGoalCatalogs.FirstOrDefault(a => a.Id == id);

            if (_item.CSPGoalCatalogs.Count() > 0)
            {
                foreach (CSPGoalCatalog Chitem in _item.CSPGoalCatalogs)
                {
                    Chitem.IsDeleted = true;
                }
            }
            _item.IsDeleted = true;
            _context.SaveChanges();
        }
        public static CSP MoveDown(int id)
        {
            SinaicspDataModelContainer _context  = new Sinaicsp_API.SinaicspDataModelContainer();
            CSPGoalCatalog             _goalItem = _context.CSPGoalCatalogs.Where(a => a.Id == id).FirstOrDefault();
            CSP _item = _goalItem.CSP;

            if (_goalItem.ParentCSPGoalCatalogId == null)
            {
                List <CSPGoalCatalog> targetParentList = _item.CSPGoalCatalogs.Where(a => a.ParentCSPGoalCatalogId == null).OrderByDescending(a => a.TextOrder).ToList();
                int index = targetParentList.IndexOf(_goalItem);
                if (index > 0)
                {
                    CSPGoalCatalog _goalAbove   = targetParentList[index - 1];
                    int            NeworderSwap = _goalAbove.TextOrder;
                    _goalAbove.TextOrder = _goalItem.TextOrder;
                    _goalItem.TextOrder  = NeworderSwap;
                    foreach (CSPGoalCatalog item in _goalItem.CSPGoalCatalogs)
                    {
                        item.TextOrder = _goalItem.TextOrder;
                    }
                    foreach (CSPGoalCatalog item in _goalAbove.CSPGoalCatalogs)
                    {
                        item.TextOrder = _goalAbove.TextOrder;
                    }
                }
            }
            else
            {
                CSPGoalCatalog        _parent         = _goalItem.ParentCSPGoalCatalog;
                List <CSPGoalCatalog> targetchildList = _parent.CSPGoalCatalogs.OrderByDescending(a => a.SubTextOrder).ToList();

                int index = targetchildList.IndexOf(_goalItem);
                if (index > 0)
                {
                    CSPGoalCatalog _goalAbove   = targetchildList[index - 1];
                    int            NeworderSwap = _goalAbove.SubTextOrder;
                    _goalAbove.SubTextOrder = _goalItem.SubTextOrder;
                    _goalItem.SubTextOrder  = NeworderSwap;
                }
            }
            _context.SaveChanges();
            return(_item);
        }