Ejemplo n.º 1
0
        /// <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;
            }
        }
Ejemplo n.º 2
0
 partial void UpdateProject(Project instance);
Ejemplo n.º 3
0
 partial void DeleteProject(Project instance);
Ejemplo n.º 4
0
 partial void InsertProject(Project instance);