Example #1
0
        public async Task <ActionResult <ClassroomViewModel> > PostClassroom(ClassroomViewModel classroom)
        {
            if (classroom != null)
            {
                try
                {
                    await Task.Run(() =>
                    {
                        classroom.DateCreated = DateTime.Now;
                        _classroomService.Add(classroom);
                        _classroomService.SaveChanges();
                        return(Ok("Thêm phòng học thành công!"));
                    });
                }
                catch
                {
                    throw new Exception(string.Format("Lỗi khi thêm dữ liệu"));
                }
            }

            return(CreatedAtAction("GetReceiptType", new { id = classroom.Id }, classroom));
        }