public bool Validate(string rota, string authorization) { var retorno = new HttpResult <IActionResult>(); var serviceRotaToggle = ServiceRotaToggleEntityService.GetAll().Result.Where(x => x.Rota == rota).FirstOrDefault(); var toggle = ToggleEntityService.Get(serviceRotaToggle.Toggle.Id); var toggleServiceRotas = toggle.Result.ToggleServiceRotas; var serviceRota = ServiceRotaEntityService.GetAll().Result.Where(x => x.Authorization == authorization).FirstOrDefault(); if (toggleServiceRotas != null && toggleServiceRotas.Count == 0) { return(true); } foreach (var toggleServiceRota in toggle.Result.ToggleServiceRotas) { if (toggleServiceRota.ServiceRota.Id == serviceRota.Id) { return(true); } continue; } return(false); }
public HttpResult <Order> Register(Order order, string authorization, string rota) { var retorno = new HttpResult <Order>(); var retornoServiceRotaToggleGetAll = ServiceRotaToggleEntityService.GetAll().Result.Where(x => x.Rota == rota).FirstOrDefault(); if (retornoServiceRotaToggleGetAll == null) { return(retorno.SetHttpStatusToNotFound()); } var retornoServiceRotaGetAll = ServiceRotaEntityService.GetAll().Result.Where(x => x.Authorization == authorization).FirstOrDefault(); if (retornoServiceRotaGetAll == null) { return(retorno.SetHttpStatusToNotFound()); } order.DescriptionToggle = retornoServiceRotaToggleGetAll.Toggle.Description; order.DescriptionServiceRota = retornoServiceRotaGetAll.Rota; _dbContext.Context.Order.Add(order); _dbContext.SaveChanges(); retorno.Response = order; retorno.SetHttpStatusToCreated(); return(retorno); }