コード例 #1
0
    public UpdateResult Update(ObjectId Id, SimpleCourseDTO course)
    {
        var filter = Builders <Course> .Filter.Eq("Id", Id);

        var update = Builders <Course> .Update.Set("Name", course.Name).Set("Code", course.Code);

        return(_collection.UpdateOne(filter, update));
    }
コード例 #2
0
        public ActionResult <Course> Post([FromBody] SimpleCourseDTO courseDto)
        {
            var course = new Course
            {
                Id   = ObjectId.GenerateNewId(),
                Name = courseDto.Name,
                Code = courseDto.Code
            };

            _courseRepository.Add(course);
            return(course);
        }
コード例 #3
0
        public ActionResult <UpdateResult> Put(string id, [FromBody] SimpleCourseDTO course)
        {
            var OId = ObjectId.Parse(id);

            return(this._courseRepository.Update(OId, course));
        }