Но в таком случае легко опечататься и потом искать, почему фронт не отображает ошибку. Поэтому хочу сделать обертку, знаю что можно вот так:
public static class CBExt
{
public static BadRequestObjectResult BadRequestWithMessage(this Controller ctr, string message)
{
return ctr.BadRequest(new { errMessage = message });
}
}
public class CustomControllerBase: ControllerBase
{
public new IActionResult BadRequest(string[] message)
{
return base.BadRequest(new { errMessage = message });
}
}
public async Task<Teacher> GetTeacher(Guid teacherId)
{
var teacher = await _uniDbContext
.Teachers
.Include(x => x.Cources)
.FirstOrDefaultAsync(t => t.Id == teacherId);
return teacher;
}
public async Task<bool> IsDublicated(string label)
{
var existedProduct = await _context.Set<Product>()
.FirstOrDefaultAsync(property => property.Label.ToLower() == label.ToLower());
return existedProduct != null;
}
if (await _unitOfWork.ProductRepository.IsDublicated(product.Label))
{
throw new DataDublication("Label already exists.");
}
public static void Main(string[] args)
{
// подождет 1с и вызовет SomeMethod 1 раз
var t1 = new System.Threading.Timer(SomeWork, null, TimeSpan.FromSeconds(1), TimeSpan.Zero);
// подождет 5с и будет вызывать SomeMethod раз в секунду
var t2 = new System.Threading.Timer(SomeWork, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(1));
Console.ReadKey();
}
public static void SomeWork(object state)
{
Console.WriteLine("work");
}
как мне фильтровать полученные данные и по каким критериям
Redirect is not allowed for a preflight request.