Пример #1
0
        private WBS CreateNewProjectFromFields()
        {
            WBS wbs = new WBS();

            wbs.Name        = NewWBSName;
            wbs.Description = NewWBSDescription;
            wbs.Code        = NewWBSCode;
            wbs.TaxArea     = NewWBSTaxArea;
            wbs.CreatedDate = DateTimeOffset.Now.ToUnixTimeSeconds();

            return(wbs);
        }
Пример #2
0
        private void AddWBS()
        {
            WBS wbs = CreateNewProjectFromFields();

            string tempStatusMessage;

            if (!WBSisValid(wbs, out tempStatusMessage))
            {
                StatusMessage = tempStatusMessage;
                return;
            }

            _DBcontext.InsertIntoDatabase(wbs);
            StatusMessage = "WBS successfully added.";

            // Update wbs observable collection to include new item
            WBSs.Add(wbs);

            ResetNewWBSFields();
        }
Пример #3
0
        private bool WBSisValid(WBS wbs, out string statusMessage)
        {
            // Check for empty attributes
            if (string.IsNullOrWhiteSpace(wbs.Name))
            {
                statusMessage = "Name cannot be empty.";
                return(false);
            }
            else if (string.IsNullOrWhiteSpace(wbs.Code))
            {
                statusMessage = "Code cannot be empty.";
                return(false);
            }
            else if (string.IsNullOrWhiteSpace(wbs.TaxArea))
            {
                statusMessage = "Tax Area cannot be empty.";
                return(false);
            }

            // Check for duplicate WBS objects
            bool duplicateName = _DBcontext.WBSs.SingleOrDefault(w => w.Name == wbs.Name) != null;
            bool duplicateCode = _DBcontext.WBSs.SingleOrDefault(w => w.Code == wbs.Code) != null;

            if (duplicateName)
            {
                statusMessage = "Duplicate WBS name found.";
            }
            else if (duplicateCode)
            {
                statusMessage = "Duplicate WBS code found.";
            }
            else
            {
                statusMessage = "Success";
            }

            return(!(duplicateName || duplicateCode));
        }