public TopicViewModel(Topic topic)
 {
     this.ID = topic.ID;
     this.Name = topic.Name;
     this.IsActive = topic.IsActive;
     this.Course = new CourseViewModel(topic.Cours);
     this.ActiveFrom = topic.ActiveFrom;
     this.ActiveTo = topic.ActiveTo;
 }
示例#2
0
        /// <summary>
        /// Creates new Topic
        /// </summary>
        /// <param name="name">Topic name</param>
        /// <param name="isActive">Topic state</param>
        public static void Create(string name, Cours course, bool isActive)
        {
            Topic c = new Topic();
            c.Cours = course;
            c.Name = name;
            c.IsActive = isActive;

            db.AddToTopics(c);
        }
 /// <summary>
 /// Creates the specified Submission.
 /// </summary>
 /// <param name="student">The student.</param>
 /// <param name="topic">The topic.</param>
 /// <param name="uploadDate">The upload date.</param>
 /// <param name="Extension">Type of the MIME.</param>
 /// <param name="fileData">The file data.</param>
 public static void Create(Student student, Topic topic, Cours course, DateTime uploadDate, string Extension, string filePath)
 {
     Submission s = new Submission();
     s.Student = student;
     s.Cours = course;
     s.Topic = topic;
     s.UploadDate = uploadDate;
     s.Extension = Extension;
     s.FilePath = filePath.Trim();
     db.Submissions.AddObject(s);
     db.SaveChanges();
 }
        public ActionResult Create(Topic topic)
        {
            if (ModelState.IsValid)
            {
                db.Topics.AddObject(topic);
                db.SaveChanges();
                return PartialView("GridData", new Topic[] { topic });
            }

            ViewBag.CourseID = new SelectList(db.Courses, "ID", "Name", topic.CourseID);
            return PartialView("Edit", topic);
        }
        public ActionResult Edit(Topic topic)
        {
            if (ModelState.IsValid)
            {
                db.Topics.Attach(topic);
                db.ObjectStateManager.ChangeObjectState(topic, EntityState.Modified);
                db.SaveChanges();
                return PartialView("GridData", new Topic[] { topic });
            }

            ViewBag.CourseID = new SelectList(db.Courses, "ID", "Name", topic.CourseID);
            return PartialView(topic);
        }
        public static List<Topic> GenerateTopics(int numberTopics)
        {
            List<Topic> topics = new List<Topic>();

            for (int i = 0; i < numberTopics; i++)
            {
                Topic t = new Topic();
                DateTime startDate = Faker.DateTimeFaker.DateTimeBetweenMonths(2, 3);
                DateTime endDate = Faker.DateTimeFaker.DateTimeBetweenMonths(3, 5);
                bool isActive = true;
                string name = UppercaseFirst(Faker.CompanyFaker.BS());

                t.ActiveFrom = startDate;
                t.ActiveTo = endDate;
                t.IsActive = isActive;
                t.Name = name;

                topics.Add(t);
            }
            return topics;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Topics EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTopics(Topic topic)
 {
     base.AddObject("Topics", topic);
 }
 /// <summary>
 /// Create a new Topic object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="courseID">Initial value of the CourseID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="isActive">Initial value of the IsActive property.</param>
 public static Topic CreateTopic(global::System.Int32 id, global::System.Int32 courseID, global::System.String name, global::System.Boolean isActive)
 {
     Topic topic = new Topic();
     topic.ID = id;
     topic.CourseID = courseID;
     topic.Name = name;
     topic.IsActive = isActive;
     return topic;
 }
示例#9
0
 /// <summary>
 /// Adds to course.
 /// </summary>
 /// <param name="topic">The topic.</param>
 /// <param name="course">The course.</param>
 public static void AddToCourse(Topic topic, Cours course)
 {
     topic.Cours = course;
     db.SaveChanges();
 }
示例#10
0
 /// <summary>
 /// Updates the specified Topic.
 /// </summary>
 /// <param name="Topic">The Topice.</param>
 /// <param name="name">Topice's Name</param>
 /// <param name="isActive">The Topice's state</param>
 public static void Update(Topic topic, string name, bool isActive, DateTime activeFrom, DateTime activeTo)
 {
     topic.Name = name;
     topic.ActiveFrom = activeFrom;
     topic.ActiveTo = activeTo;
     topic.IsActive = isActive;
     db.SaveChanges();
 }
 /// <summary>
 /// Adds submission to topic.
 /// </summary>
 /// <param name="topic">The topic.</param>
 /// <param name="submission">The submission.</param>
 public static void AddToTopic(Topic topic, Submission submission)
 {
     submission.Topic = topic;
     db.SaveChanges();
 }