Пример #1
0
        public IActionResult Add([FromBody] Lectur lectur)
        {
            try
            {
                lectur.Id      = Guid.NewGuid();
                lectur.Seminar = _dbContext.Seminars.FirstOrDefault(p => p.Id == lectur.Seminar.Id);
                var result = _dbContext.Lecturs.Add(lectur);
                _dbContext.SaveChanges();

                return(Ok(result));
            }
            catch
            {
                return(StatusCode(505));
            }
        }
Пример #2
0
        public IActionResult Update([FromBody] Lectur lectur)
        {
            try
            {
                var currentEntity = _dbContext.Lecturs.FirstOrDefault(p => p.Id == lectur.Id);

                currentEntity.Topic    = lectur.Topic;
                currentEntity.Lecturer = lectur.Lecturer;
                currentEntity.StartAt  = lectur.StartAt;
                currentEntity.EndAt    = lectur.EndAt;
                currentEntity.Seminar  = lectur.Seminar;
                _dbContext.Lecturs.Update(currentEntity);
                _dbContext.SaveChanges();

                return(Ok());
            }
            catch
            {
                return(StatusCode(505));
            }
        }