public void Handle(NewBenefitDefinedEvent args) { if (_mongoDataBase.CollectionExists("Benefits") == false) { _mongoDataBase.CreateCollection("Benefits"); } var benefitsCollection = _mongoDataBase.GetCollection <BenefitDto>("Benefits"); var benefit = new BenefitDto { Id = args.BenefitId, BenefitType = args.BenefitType, Description = args.BenefitDescription, HasMaxElectionAmount = args.HasMaxElectionAmount, MaxElectionAmount = args.MaxElectionAmount, PlanId = args.PlanId, CompanyId = args.CompanyId, }; var safeModeResult = benefitsCollection.Save(benefit); if (!safeModeResult.Ok) { //log! //push a message to an admin q? } }
public static string GetDetailUrl(this BenefitDto benefit) { var urlhelper = new UrlHelper(HttpContext.Current.Request.RequestContext); var detailurl = urlhelper.Action("Detail", "Benefit", routeValues: new { area = "", benefit.Id }); return(detailurl); }
public static string GetDefaultImageUrl(this BenefitDto benefit, int width = 50, int height = 50) { var urlhelper = new UrlHelper(HttpContext.Current.Request.RequestContext); var url = benefit.DefaultFileId.HasValue ? urlhelper.Action("Image", "File", new { area = "", id = benefit.DefaultFileId, width = width, height = height }) : urlhelper.GetNoImageUrl(width, height); return(url); }