Esempio n. 1
0
        public int AddProjectElement(Project project, ProjectElement pe)
        {
            if (project == null || pe == null)
            {
                return -1;
            }

            try
            {
                project.projectElements.Add(pe);
                project.dateModified = DateTime.Now;

                VestnDB db = new VestnDB();
                db.projectElements.Add(pe);
                db.Entry(project).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch (Exception e)
            {
                logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), e.ToString());
                return -1;
            }

            try
            {
                if (project.projectElementOrder == null)
                {
                    if (project.projectElements.Count > 1)
                    {
                        project = resetProjectElementOrder(project);
                        //project.projectElementOrder += "," + pe.id;
                    }
                    else
                    {
                        project.projectElementOrder += pe.id;
                    }
                }
                else
                {
                    //project.projectElementOrder += "," + pe.id;
                    project.projectElementOrder = pe.id + "," + project.projectElementOrder; // add new element to the begininning of the order
                }
                VestnDB db = new VestnDB();
                db.Entry(project).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch (Exception e)
            {
                logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), e.ToString());
                return -1;
            }

            return pe.id;
        }
Esempio n. 2
0
 /// <summary>
 /// deletes a project element from the order or project elements within a project
 /// </summary>
 /// <param name="Project p"></param>
 /// <param name="ProjectElement element"></param>
 private void DeleteElementOrder(Project p, ProjectElement element)
 {
     projectManager.deleteProjectElementFromOrder(p, element.id);
 }
Esempio n. 3
0
 public JsonModels.Artifact GetArtifactJson(ProjectElement element)
 {
     JsonModels.Artifact artifactJson = new JsonModels.Artifact();
     if (element != null)
     {
         artifactJson.description = element.description;
         artifactJson.title = element.title;
         artifactJson.id = element.id;
         if (element.GetType() == typeof(ProjectElement_Document))
         {
             ProjectElement_Document ped = (ProjectElement_Document)element;
             artifactJson.artifactLocation = ped.documentThumbnailLocation;
             artifactJson.fileLocation = ped.documentLocation;
             artifactJson.type = "document";
             return artifactJson;
         }
         else if (element.GetType() == typeof(ProjectElement_Picture))
         {
             ProjectElement_Picture pep = (ProjectElement_Picture)element;
             artifactJson.artifactLocation = pep.pictureThumbnailLocation;
             artifactJson.fileLocation = pep.pictureLocation;
             artifactJson.type = "picture";
             return artifactJson;
         }
         else if (element.GetType() == typeof(ProjectElement_Audio))
         {
             ProjectElement_Audio pea = (ProjectElement_Audio)element;
             artifactJson.artifactLocation = pea.audioLocation;
             artifactJson.fileLocation = pea.audioLocation;
             artifactJson.type = "audio";
             return artifactJson;
         }
         else if (element.GetType() == typeof(ProjectElement_Code))
         {
             ProjectElement_Code pec = (ProjectElement_Code)element;
             artifactJson.artifactLocation = pec.code;
             artifactJson.fileLocation = pec.type;
             artifactJson.type = "code";
             return artifactJson;
         }
         else if (element.GetType() == typeof(ProjectElement_Video))
         {
             ProjectElement_Video pev = (ProjectElement_Video)element;
             artifactJson.artifactLocation = pev.videoId;
             artifactJson.fileLocation = pev.videoType;
             artifactJson.type = "video";
             return artifactJson;
         }
         else
         {
             return null;
         }
     }
     else
     {
         return null;
     }
 }
Esempio n. 4
0
 public ProjectElement DeleteProjectElement(ProjectElement pe)
 {
     return pa.DeleteProjectElement(pe);
     //add logic here to actually delete the pictures from blob storage -- need to ask brian how to do that jtaylor
 }
Esempio n. 5
0
 public int AddProjectElement(Project project, ProjectElement pe)
 {
     return pa.AddProjectElement(project, pe);
 }
Esempio n. 6
0
 public ProjectElement UpdateProjectElement(ProjectElement pe)
 {
     return pa.UpdateProjectElement(pe);
 }
Esempio n. 7
0
 public ProjectElement UpdateProjectElement(ProjectElement pe)
 {
     if (GetProjectElement(pe.id) == null)
     {
         return null;
     }
     try
     {
         VestnDB db = new VestnDB();
         db.Entry(pe).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception e)
     {
         logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), e.ToString());
         return null;
     }
     return pe;
 }
Esempio n. 8
0
 public ProjectElement DeleteProjectElement(ProjectElement pe)
 {
     VestnDB db = new VestnDB();
     db.projectElements.Attach(pe);
     db.projectElements.Remove(pe);
     db.SaveChanges();
     return pe;
 }