Пример #1
0
        public ProjectVM AddProject(ProjectVM project)
        {
            Project model = new Project()
            {
                ProjectName = project.ProjectName,
                CompletionDate = project.CompletionDate,
                StartDate = project.StartDate,
                TargetDate = project.TargetDate,
                DateDeleted = null,
                ProjectID = project.ProjectID,
                Address1 = project.Address1,
                Address2 = project.Address2,
                City = project.City,
                State = project.State,
                Zip = project.Zip,
                LocationNotes = project.LocationNotes,
                Solutions = project.Solutions.Select(x => new Solution()
                {
                    SolutionID = x.SolutionID,
                    StartDate = x.StartDate,
                    SolutionName = x.SolutionName,
                    ProjectID = project.ProjectID,
                    DateDeleted = null,
                    TargetCompletionDate = x.TargetCompletionDate,
                    Urgency = x.Urgency,
                    SolutionNotes = x.SolutionNotes.Select(sn => new SolutionNote()
                    {
                        DateDeleted = null,
                        DateEntered = DateTime.Now,
                        SolutionID = x.SolutionID,
                        SolutionNoteID = sn.SolutionNoteID,
                        Note = sn.Note
                    }).ToList(),
                }).ToList(),
            };

            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                db.Projects.Add(model);
                db.SaveChanges();
            }
            return project;
        }
Пример #2
0
 public void EditProject(ProjectVM project, int id)
 {
     if (project != null)
     {
         Project model;
         using (ApplicationDbContext db = new ApplicationDbContext())
         {
             model = db.Projects.FirstOrDefault(x => x.ProjectID == id);
             model.ProjectName = project.ProjectName;
             model.StartDate = project.StartDate;
             model.TargetDate = project.TargetDate;
             model.CompletionDate = project.CompletionDate;
             model.Address1 = project.Address1;
             model.Address2 = project.Address2;
             model.City = project.City;
             model.State = project.State;
             model.Zip = project.Zip;
             model.LocationNotes = project.LocationNotes;
             db.SaveChanges();
         };
     };
 }
 // project editing
 public IHttpActionResult Post(ProjectVM project, int id)
 {
     _adapter.EditProject(project, id);
     return Ok();
 }
 public IHttpActionResult Post(ProjectVM project, int id)
 {
     _adapter.DeleteProject(id);
     return Ok();
 }