Ejemplo n.º 1
0
 public void CheckSummitBadge(BadgeSummit badge)
 {
     if (badge.UnreachedSummits != null)
     {
         repository.UpdateBadgeStatus(badge.Id, "Achieved");
     }
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> PostAsync([FromBody] BadgeSummit badge)
        {
            logger.LogInformation("Adding new summit badge was called");
            try
            {
                if (ModelState.IsValid)
                {
                    badge.BadgeStatus = "Inactive";

                    await repository.AddBadge(badge);

                    if (await repository.SaveAll())
                    {
                        return(Created("api/badges", badge));
                    }
                }
            }
            catch (Exception ex)
            {
                logger.LogError($"Failed to add new summit badge: {ex}");
            }

            return(BadRequest("Failed to add new summit badge"));
        }