Beispiel #1
0
        public async Task <SaveProjectResult> SaveProjectModel()
        {
            // Project name is empty
            if (string.IsNullOrEmpty(ProjectName))
            {
                return(SaveProjectResult.NameIsEmpty);
            }

            // Project name is used
            var exists = await ExistProjectWithName(ProjectName);

            if (exists)
            {
                return(SaveProjectResult.NameExists);
            }

            model.Name  = ProjectName;
            model.Color = ProjectColor;

            // Save new project.
            await model.SaveAsync();

            // Create an extra model for Project / User relationship
            var userData = ServiceContainer.Resolve <AuthManager> ().User;

            var projectUserModel = new ProjectUserModel();

            projectUserModel.Project = model;
            projectUserModel.User    = new UserModel(userData);

            // Save relationship.
            await projectUserModel.SaveAsync();

            return(SaveProjectResult.SaveOk);
        }
        public async Task<SaveProjectResult> SaveProjectModel ()
        {
            // Project name is empty
            if (string.IsNullOrEmpty (ProjectName)) {
                return SaveProjectResult.NameIsEmpty;
            }

            // Project name is used
            var exists = await ExistProjectWithName (ProjectName);
            if (exists) {
                return SaveProjectResult.NameExists;
            }

            model.Name = ProjectName;
            model.Color = ProjectColor;

            // Save new project.
            await model.SaveAsync();

            // Create an extra model for Project / User relationship
            var userData = ServiceContainer.Resolve<AuthManager> ().User;

            var projectUserModel = new ProjectUserModel ();
            projectUserModel.Project = model;
            projectUserModel.User = new UserModel (userData);

            // Save relationship.
            await projectUserModel.SaveAsync ();

            return SaveProjectResult.SaveOk;
        }
        public async Task<ProjectData> SaveProject (string projectName, int projectColor)
        {
            model.Name = projectName;
            model.Color = projectColor;

            // Save new project.
            await model.SaveAsync();

            // Create an extra model for Project / User relationship
            var userData = ServiceContainer.Resolve<AuthManager>().User;

            var projectUserModel = new ProjectUserModel();
            projectUserModel.Project = model;
            projectUserModel.User = new UserModel (userData);

            // Save relationship.
            await projectUserModel.SaveAsync();

            return model.Data;
        }
        public async Task <ProjectData> SaveProject(string projectName, int projectColor)
        {
            model.Name  = projectName;
            model.Color = projectColor;

            // Save new project.
            await model.SaveAsync();

            // Create an extra model for Project / User relationship
            var userData = ServiceContainer.Resolve <AuthManager>().User;

            var projectUserModel = new ProjectUserModel();

            projectUserModel.Project = model;
            projectUserModel.User    = new UserModel(userData);

            // Save relationship.
            await projectUserModel.SaveAsync();

            return(model.Data);
        }
Beispiel #5
0
        public async Task SaveProjectModel()
        {
            // Save new project.
            await model.SaveAsync();

            // Create an extra model for Project / User relationship
            var userData = ServiceContainer.Resolve <AuthManager> ().User;
            var userId   = userData != null ? userData.Id : (Guid?)null;

            if (userId.HasValue)
            {
                var projectUserModel = new ProjectUserModel();
                projectUserModel.Project = model;
                projectUserModel.User    = new UserModel(userId.Value);
                await projectUserModel.SaveAsync();
            }

            // Update entry list.
            var timeEntryGroup = new TimeEntryGroup(timeEntryList);

            timeEntryGroup.Project   = model;
            timeEntryGroup.Workspace = workspaceModel;
            await timeEntryGroup.SaveAsync();
        }