private async Task DeleteProject()
        {
            if (SelectedProject != null)
            {
                if (MessageBox.Show($"Are you sure you want to delete {SelectedProject.Title} ?", "Delete Record", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
                {
                    return;
                }
                CanDeleteProject = false;
                try
                {
                    HttpResponseMessage result = await apiHelper.DeleteProject(ParentLayout.LoggedInUser.Token, SelectedProject.ID).ConfigureAwait(false);

                    if (result.IsSuccessStatusCode)
                    {
                        await GetProjects();

                        await ParentLayout.GetProjects();

                        ClearFields();
                    }
                    else
                    {
                        MessageBox.Show("Error in deleting Project", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    CanDeleteProject = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    CanDeleteProject = true;
                }
            }
            else
            {
                MessageBox.Show("Please select a Project to be deleted", "Select Project", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        private async Task CreateProject()
        {
            try
            {
                List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("Title", Title),
                    new KeyValuePair <string, string>("Project Type", TypeText),
                    new KeyValuePair <string, string>("Project Status", StatusText),
                    new KeyValuePair <string, string>("Firm", FirmText),
                    new KeyValuePair <string, string>("Address", Address)
                };
                if (FieldValidation.ValidateFields(values))
                {
                    if (Contractors.Where(c => c.IsChecked).Count() <= 0)
                    {
                        MessageBox.Show("Please add atleast 1 Contractor to the Project", "Add Contractor", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                    else if (Suppliers.Where(c => c.IsChecked).Count() <= 0)
                    {
                        MessageBox.Show("Please add atleast 1 Supplier to the Project", "Add Supplier", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                    else
                    {
                        CanSaveProject = false;

                        List <ProjectContractorsModel> projectContractors = new List <ProjectContractorsModel>();
                        List <ProjectSuppliersModel>   projectSuppliers   = new List <ProjectSuppliersModel>();

                        Contractors.Where(s => s.IsChecked).ToList().ForEach(s => projectContractors.Add(
                                                                                 new ProjectContractorsModel
                        {
                            ProjectID    = ID,
                            ContractorID = s.ID,
                        }));

                        Suppliers.Where(s => s.IsChecked).ToList().ForEach(s => projectSuppliers.Add(
                                                                               new ProjectSuppliersModel
                        {
                            ProjectID  = ID,
                            SupplierID = s.ID,
                        }));

                        ProjectModel projectData = new ProjectModel()
                        {
                            Title         = Title,
                            Description   = Description,
                            ProjectTypeID = SelectedType?.ID,
                            Type          = SelectedType == null ? new TypeModel {
                                Title = TypeText, CreatedBy = ParentLayout.LoggedInUser.Name
                            } : null,
                            ProjectStatusID = SelectedStatus?.ID,
                            Status          = SelectedStatus == null ? new StatusModel {
                                Title = StatusText, CreatedBy = ParentLayout.LoggedInUser.Name
                            } : null,
                            FirmID = SelectedFirm?.ID,
                            Firm   = SelectedFirm == null ? new FirmModel {
                                Name = FirmText, CreatedBy = ParentLayout.LoggedInUser.Name
                            } : null,
                            StartDate   = StartDate,
                            DueDate     = DueDate,
                            Address     = Address,
                            TeamID      = SelectedTeam?.ID,
                            Contractors = projectContractors,
                            Suppliers   = projectSuppliers
                        };

                        HttpResponseMessage result = null;
                        if (isUpdate)
                        {
                            projectData.ID         = ID;
                            projectData.CreatedBy  = SelectedProject.CreatedBy;
                            projectData.CreatedOn  = SelectedProject.CreatedOn;
                            projectData.ModifiedBy = ParentLayout.LoggedInUser.Name;
                            projectData.ModifiedOn = DateTime.Now;
                            result = await apiHelper.PutProject(ParentLayout.LoggedInUser.Token, projectData).ConfigureAwait(false);
                        }
                        else
                        {
                            projectData.CreatedBy = ParentLayout.LoggedInUser.Name;
                            projectData.CreatedOn = DateTime.Now;
                            result = await apiHelper.PostProject(ParentLayout.LoggedInUser.Token, projectData).ConfigureAwait(false);
                        }
                        if (result.IsSuccessStatusCode)
                        {
                            MessageBox.Show($"Project Saved Successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                            await GetProjects();

                            await ParentLayout.GetProjects();

                            IsUpdate = false;
                            ClearFields();
                            await GetContractors();
                            await GetSuppliers();
                            await GetTypes();
                            await GetStatuses();
                            await GetFirms();
                        }
                        else
                        {
                            MessageBox.Show("Error in saving Project", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        CanSaveProject = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                CanSaveProject = true;
            }
        }