Beispiel #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;
        }
 public Activity UpdateActivity(Activity activity)
 {
     try
     {
         if (activity != null)
         {
             VestnDB db = new VestnDB();
             db.Entry(activity).State = EntityState.Modified;
             db.SaveChanges();
             return activity;
         }
         else
         {
             return null;
         }
     }
     catch (Exception e)
     {
         logAccessor.CreateLog(DateTime.Now, "ActivityAccessor - UpdateActivity", e.StackTrace);
         return null;
     }
 }
Beispiel #3
0
 public sTag UpdateSTag(sTag tag)
 {
     sTag oldTag = GetSTag(tag.id);
     if (oldTag.value != tag.value)
     {
         return tag;
     }
     try
     {
         VestnDB db = new VestnDB();
         db.Entry(tag).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch (InvalidOperationException)
     {
         return null;
     }
     return tag;
 }
        private void fillProjects(User u)
        {
            VestnDB vestnDB = new VestnDB();
            Project project = new Project
            {
                name = "Test Project",
                description = "Test Description",
            };

            //Project Elements
            ProjectElement_Information informationElement;
            ProjectElement_Experience experienceElement;
            ProjectElement_Document documentElement;
            ProjectElement_Video videoElement;
            ProjectElement_Picture pictureElement;
            List<ProjectElement> projectElements;

            informationElement = new ProjectElement_Information
            {

                location = "Here",
                email = "*****@*****.**",
                school= "Univeristy of Nebraska- Lincoln",
                phone = "402-402-4111",
                major = "Actuarial Science",
                minor = "Business Administration",
                description = "tetetetetet"
            };
            documentElement = new ProjectElement_Document
            {
                description = "im a document",
                documentLocation = "asdfasdf"
            };
            experienceElement = new ProjectElement_Experience
            {
                jobTitle = "Owner",
                description = "I'm CEO Bitch.",
                startDate = new DateTime(1991, 6, 12),
                endDate = new DateTime(2011, 6, 12)
            };
            pictureElement = new ProjectElement_Picture
            {
                description = "im a picture",
                pictureLocation = "sadfsadfsa"
            };
            videoElement = new ProjectElement_Video
            {
                //put a test id you know in here haun
                videoId = "xxxxx",
                description = "asdfsadfasdf"
            };

            projectElements = new List<ProjectElement>();
            projectElements.Add(informationElement);
            projectElements.Add(experienceElement);
            projectElements.Add(documentElement);
            projectElements.Add(pictureElement);
            projectElements.Add(videoElement);

            //Save elements to project
            project.projectElements = projectElements;

            //Save Changes to DB
            VestnDB db = new VestnDB();
            db.projects.Add(project);
            if (u.projects == null)
            {
                u.projects = new List<Project>();
            }
            u.projects.Add(project);
            db.Entry(u).State = EntityState.Modified;
            db.SaveChanges();
        }
Beispiel #5
0
 private User UpdateEntityUser(User user)
 {
     //Entity logic for username update
     try
     {
         VestnDB db = new VestnDB();
         db.Entry(user).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 user;
 }
Beispiel #6
0
 public Reference UpdateReference(Reference reference)
 {
     try
     {
         if (reference != null)
         {
             VestnDB db = new VestnDB();
             db.Entry(reference).State = EntityState.Modified;
             db.SaveChanges();
             return reference;
         }
         else
         {
             return null;
         }
     }
     catch (Exception e)
     {
         logAccessor.CreateLog(DateTime.Now, "userAccessor - UpdateReference", e.StackTrace);
         return null;
     }
 }
Beispiel #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;
 }
Beispiel #8
0
 public Prop UpdateProp(Prop prop)
 {
     try
     {
         if (prop != null)
         {
             VestnDB db = new VestnDB();
             db.Entry(prop).State = EntityState.Modified;
             db.SaveChanges();
             return prop;
         }
         else
         {
             return null;
         }
     }
     catch (Exception e)
     {
         logAccessor.CreateLog(DateTime.Now, "PropAccessor - UpdateProp", e.StackTrace);
         return null;
     }
 }