public static bool EqualValues(this BadgeDto badgeDto, Badge badge) { bool equal = badgeDto.Field == badge.Field && badgeDto.ID == badge.ID && badgeDto.Name == badge.Name && badgeDto.Threshold == badge.Threshold; return(equal); }
public IHttpActionResult GetBadge(long id) { var b = badgeSvc.GetBadge(id); if (b == null) { return(NotFound()); } return(Ok(BadgeDto.FromBadge(b))); }
public ActionResult CoffeeMachine(string idBadge) { List <DrinkTypeDto> drinkTypesList = _drinkTypesRepository.Get(); CoffeeMachineViewModel model = new CoffeeMachineViewModel(); model.DrinkTypesList = new SelectList(drinkTypesList.OrderBy(x => x.Id), "Id", "Label", null, 1, null); if (!string.IsNullOrEmpty(idBadge)) { BadgeDto badge = _badgeRepository.Get(idBadge); model.SugarQuantity = badge.Drink.Sugar.Quantity; model.IsOwerMug = badge.IsOwerMug; model.DrinkType = badge.Drink.Type.Id; } return(View(model)); }
public async Task <ActionResult <List <DashboardDto> > > PostBadge([FromBody] BadgeDto badge) { try { Logger.LogInformation($"PostBadge()"); var values = await Mediator.Send(new SaveBadgeCommand(badge)); Logger.LogInformation(Request.Path); return(Ok(values)); } catch (Exception ex) { Logger.LogError($"PostBadge Failed: {ex.Message}", ex); return(Ok(HttpStatusCode.InternalServerError)); } }
public async Task <List <DashboardDto> > Handle(GetDashboardCommand request, CancellationToken cancellationToken) { var dashboard = new List <DashboardDto>(); try { // get apps var apps = await _executor.Execute(new GetAppsQuery(request.OrgId)); if (apps == null || apps.Count == 0) { throw new ThisAppException(StatusCodes.Status404NotFound, "No Apps found"); } // get stages var stages = await _executor.Execute(new GetStagesQuery(request.OrgId)); if (stages == null || stages.Count == 0) { throw new ThisAppException(StatusCodes.Status404NotFound, "No Stages found"); } // get badge urls foreach (var app in apps) { var dto = new DashboardDto { AppId = app.Id, AppName = app.Name, Stages = new List <BadgeDto>() }; foreach (var stage in stages) { var badge = await _executor.CastTo <BadgeDto>().Execute(new GetBadgeQuery(app.Id, stage.Id)); if (badge == null) { badge = new BadgeDto { Id = 0, AppId = app.Id, StageId = stage.Id, BadgeUrl = "" } } ; // Filler object for the display grid. Info can be used for CRUD operation. dto.Stages.Add(badge); } dashboard.Add(dto); } } catch (Exception ex) { throw new Exception(ex.Message); } return(dashboard); }
// GET: api/Badges public IEnumerable <BadgeDto> GetBadges() { return(badgeSvc.GetBadges().Select(b => BadgeDto.FromBadge(b))); }
public void InitForView(BadgeDto badge) { SugarQuantity = badge.Drink.Sugar.Quantity; IsOwerMug = badge.IsOwerMug; DrinkType = badge.Drink.Type.Id; }