예제 #1
0
        public async Task <IActionResult> Create([FromBody] CreateRecordRequest request)
        {
            var record = new Record
            {
                Id          = Guid.NewGuid(),
                Teacher     = request.Teacher,
                Room        = request.Room,
                Note        = request.Note,
                ClassNumber = request.ClassNumber,
                ClassLetter = request.ClassLetter,
                Lessons     = request.Lessons,
                Date        = request.Date
            };

            var created = await _recordTempService.CreateTempRecord(record);

            if (created == false)
            {
                return(BadRequest());
            }

            var baseUrl     = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}";
            var locationUri = baseUrl + "/" + ApiRoutes.TempRecords.Get.Replace("{recordId}", record.Id.ToString());

            var response = new RecordResponse {
                Id = record.Id
            };

            return(Created(locationUri, response));
        }