예제 #1
0
        public async Task <IActionResult> PostDailypoGroupReport([FromBody] DailypoGroupReport dailypoGroupReport)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.DailypoGroupReport.Add(dailypoGroupReport);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (DailypoGroupReportExists(dailypoGroupReport.GroupCode))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetDailypoGroupReport", new { id = dailypoGroupReport.GroupCode }, dailypoGroupReport));
        }
예제 #2
0
        public async Task <IActionResult> PutDailypoGroupReport([FromRoute] string id, [FromBody] DailypoGroupReport dailypoGroupReport)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != dailypoGroupReport.GroupCode)
            {
                return(BadRequest());
            }

            _context.Entry(dailypoGroupReport).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DailypoGroupReportExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }