public async Task <ObjectResponse> CreateWidgetAsync(CreateWidgetDto input) { ObjectResponse reponse = new ObjectResponse(); try { await _widgetManager.CreateWidget( input.Name, input.Owner, input.Logo, input.WelcomeMessage, input.PrimaryColor, input.TeamIntro, input.BackgroundColor, input.ObjectConfigs ); reponse.message = "Ok"; return(reponse); } catch (Exception ex) { var er = ex.Message; reponse.error.Add(er); return(reponse); } }
public async Task <IHttpActionResult> CreateAsync(CreateWidgetDto createWidgetDto) { var newWidget = TileWidget.Build(CurrentUser.Id, createWidgetDto.Name, createWidgetDto.Name, createWidgetDto.Url); _repository.Add(newWidget); await _unitOfWork.CompleteAsync(); return(Created(new Uri(Request.RequestUri + "/" + newWidget.Id), newWidget)); }
public async Task <ActionResult <object> > CreateWidget([FromBody] CreateWidgetDto input) { ObjectResponse response = new ObjectResponse(); response = await _widgetService.CreateWidgetAsync(input); response.data = null; if (response.error.Count < 1 || response.error == null) { return(Ok(response)); } else { return(BadRequest()); } }