Exemple #1
0
        public IActionResult DeleteHoliday([FromBody] Guid NewHoliday)
        {
            if (ModelState.IsValid)
            {
                var CheckGuid = _context.PublicHolidays.Find(NewHoliday);
                if (CheckGuid == null)                         // Checking if user input Guid is in database
                {
                    return(NotFound());                        // If Guid is not in database, return 404 error
                }
                _dataAccessProvider.DeleteHoliday(NewHoliday); // If Guid is in database, delete the row in database

                return(Ok());                                  // return successfully deleted
            }
            return(BadRequest(ModelState));                    // if ModelState not valid, show error message
        }