public ActionResult Create(repairDto repair) { var random = new Random(); if (!ModelState.IsValid) { return(BadRequest(modelState: ModelState)); } repair.Code = new string(Enumerable.Repeat("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 4) .Select(s => s[random.Next(s.Length)]).ToArray()); var client = clientRepository.GetById(repair.Client); var rep = new Repair() { Amount = repair.Amount, Code = repair.Code, Element = elementRepository.GetById(repair.Element), Observations = repair.Observations, IsActive = true, Status = "En proceso" }; client.Repairs.Add(rep); clientRepository.Update(client); return(CreatedAtAction(nameof(Get), null, rep)); }
public async Task <ActionResult <ElementGetDto> > Get(Guid id) { var user = await _userRepository.GetById(AuthUserId); if (user == null) { return(Unauthorized()); } var element = await _elementRepository.GetById(id); if (element == null) { return(NotFound()); } if (element.ToDoList.UserId != user.Id) { return(Forbid()); } var elementDto = _mapper.Map <ElementGetDto>(element); return(Ok(elementDto)); }
public IEnumerable <Guid> FindElements(Session session, string locator, string value, Guid?elementId) { var container = elementId.HasValue ? GetUIAutomationElement(elementId.Value) : _automation.ElementFromHandle(session.Process.MainWindowHandle); var conditions = new List <IUIAutomationCondition>(); switch (locator.ToLowerInvariant()) { case "name": conditions.Add(_automation.CreatePropertyCondition(UIA_PropertyIds.UIA_ValueValuePropertyId, value)); conditions.Add(_automation.CreatePropertyCondition(UIA_PropertyIds.UIA_AutomationIdPropertyId, value)); break; case "tag name": conditions.Add(_automation.CreatePropertyCondition(UIA_PropertyIds.UIA_ControlTypePropertyId, MapControlType(value))); break; case "id": conditions.Add(_automation.CreatePropertyCondition(UIA_PropertyIds.UIA_AutomationIdPropertyId, value)); break; default: throw new VariableResourceNotFoundException(); // TODO: should this be method not supported? } var allElementIds = new List <Guid>(); var condition = _automation.CreateOrConditionFromArray(conditions.ToArray()); var results = container.FindAll(TreeScope.TreeScope_Descendants, condition); if (results != null) { for (int i = 0; i < results.Length; i++) { var element = results.GetElement(i); var id = elementId.HasValue && locator == "tag name" && value == "option" ? _elementRepository.Add(new ListItemElement(_elementRepository.GetById(elementId.Value), i)) : _elementRepository.AddByHandle(element.CurrentNativeWindowHandle.ToInt32()); allElementIds.Add(id); } } if (allElementIds.Any()) { return(allElementIds); } throw new VariableResourceNotFoundException(); }