コード例 #1
0
ファイル: Database.cs プロジェクト: rudel/ScrumNotes
        /// <summary>
        /// The create project.
        /// </summary>
        /// <param name="project">
        /// The project.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public int CreateProject(NewProject project)
        {
            // returns null if ok, 1 if fails, 2 if the project with similar name already exists
            try
            {
                project.ParsedStartDate = DateTime.Parse(project.StartDate);
                project.ParsedEstFinishDate = DateTime.Parse(project.EstFinishDate);
                var createcontext =
                    new ScrumNotesDbClassDataContext(
                        ConfigurationManager.ConnectionStrings["ScrumNotesCombinerConnectionString"].ToString());
                int? id = createcontext.Projects.Count() + 1;
                IQueryable<Project> projects = from p in createcontext.Projects
                                               where p.Allias.Equals(project.Title)
                                               select p;
                if (projects.Count() != 0)
                {
                    createcontext.Dispose();
                    return 2;
                }

                int newid = createcontext.Projects.Count() + 1;
                var record = new Project
                                 {
                                     Allias = project.Title,
                                     Comments = project.Comments,
                                     EstFinishDate = project.ParsedEstFinishDate,
                                     Id = newid,
                                     ProjectAdminId = project.Admin,
                                     StartDate = project.ParsedStartDate
                                 };
                createcontext.Projects.InsertOnSubmit(record);
                createcontext.Projects.Context.SubmitChanges();
                createcontext.Dispose();
                return 0;
            }
            catch (Exception e)
            {
                return 1;
            }
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: rudel/ScrumNotes
        public ActionResult ActionWithProject(int id, string ProjectAction)
        {
            var ScrumNotesDatabase = new Database();
            UsersList userlist = ScrumNotesDatabase.GetUsersInProject(id);
            SchedulingStatusList ssl = ScrumNotesDatabase.GetSchedulingStatuses(id);
            UsersListForProject ulfp = ScrumNotesDatabase.GetUsersForProjectRoles(id);
            _logger.Debug("Performing actions with project");
            var nproject = new NewProject(false, userlist, ProjectAction, ssl, ulfp);
            switch (ProjectAction)
            {
                case "Create":
                    nproject.AllowEdit = true;
                    nproject.ProjectAction = ProjectAction;
                    return View(nproject);
                    break;
                case "View":
                    nproject = ScrumNotesDatabase.GetProjectInfo(id);
                    nproject.SetExtraParams(false, userlist, ProjectAction, ssl, ulfp);
                    nproject.AllowEdit = false;
                    return View(nproject);
                    break;
                case "Edit":
                    nproject = ScrumNotesDatabase.GetProjectInfo(id);
                    nproject.SetExtraParams(false, userlist, ProjectAction, ssl, ulfp);
                    nproject.AllowEdit = true;
                    nproject.id = id;
                    return View(nproject);
                    break;
                case "Delete":
                    ScrumNotesDatabase.DeleteProject(id);
                    return this.RedirectToAction("Index");
                    break;
            }

            return this.View();
        }
コード例 #3
0
ファイル: Database.cs プロジェクト: rudel/ScrumNotes
 /// <summary>
 /// The modify project.
 /// </summary>
 /// <param name="project">
 /// The project.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public bool ModifyProject(NewProject project)
 {
     try
     {
         int id = project.id;
         var updatecontext =
             new ScrumNotesDbClassDataContext(
                 ConfigurationManager.ConnectionStrings["ScrumNotesCombinerConnectionString"].ToString());
         Project projectrecord = (from p in updatecontext.Projects where p.Id.Equals(id) select p).Single();
         project.ParsedStartDate = DateTime.Parse(project.StartDate);
         project.ParsedEstFinishDate = DateTime.Parse(project.EstFinishDate);
         projectrecord.Allias = project.Title;
         projectrecord.Comments = project.Comments;
         projectrecord.EstFinishDate = project.ParsedEstFinishDate;
         projectrecord.ProjectAdminId = project.Admin;
         projectrecord.StartDate = project.ParsedStartDate;
         updatecontext.SubmitChanges();
         updatecontext.Dispose();
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
コード例 #4
0
ファイル: Database.cs プロジェクト: rudel/ScrumNotes
 /// <summary>
 /// The get project info.
 /// </summary>
 /// <param name="projectId">
 /// The project id.
 /// </param>
 /// <returns>
 /// The <see cref="NewProject"/>.
 /// </returns>
 public NewProject GetProjectInfo(int projectId)
 {
     var selectioncontext =
         new ScrumNotesDbClassDataContext(
             ConfigurationManager.ConnectionStrings["ScrumNotesCombinerConnectionString"].ToString());
     var project = new NewProject();
     IQueryable<Project> selectproject = from p in selectioncontext.Projects select p;
     project.Title = selectproject.FirstOrDefault().Allias;
     project.StartDate = selectproject.FirstOrDefault().StartDate.ToString();
     project.EstFinishDate = selectproject.FirstOrDefault().EstFinishDate.ToString();
     project.Comments = selectproject.FirstOrDefault().Comments;
     selectioncontext.Dispose();
     return project;
 }
コード例 #5
0
ファイル: HomeController.cs プロジェクト: rudel/ScrumNotes
        public ActionResult ActionWithProject(NewProject newproject)
        {
            var ScrumNotesDatabase = new Database();
            switch (newproject.ProjectAction)
            {
                case "Create":
                    ScrumNotesDatabase.CreateProject(newproject);
                    this.RedirectToAction("Index");
                    return this.View(newproject);

                    break;
                case "Edit":
                    ScrumNotesDatabase.ModifyProject(newproject);
                    return this.RedirectToAction("Index");
            }

            return this.RedirectToAction("Index");
        }