public ActionResult Request() { AdRequestModel model = new AdRequestModel(); model.CanRequestAd = true; return(View(model)); }
public AdRequestModel RequestAds(AdRequestModel model) { AdRequestModel result = new AdRequestModel(); result.Email = model.Email; result.CanRequestAd = false; List <BaseAd> ads = _adRepository.GetAdsByEmail(model.Email).ToList(); if (ads.Count == 0) { result.InfoMessage = "Cette adresse email ne correspond aucune annonce."; return(result); } IDictionary <String, String> data = new Dictionary <String, String>(); data.Add("name", ads[0].CreatedBy.Firstname); data.Add("adCount", ads.Count.ToString()); data.Add("websiteAddress", _settingsProvider.WebsiteAddress); data.Add("websiteName", _settingsProvider.WebsiteName); IDictionary <String, object[]> list = new Dictionary <String, object[]>(); list.Add("ads", ads.ToArray()); String subject = "BEA Vos Annonces"; String body = _templatingServices.GetTemplatedDocument("AdsRequestEmail.vm", data, list); _emailServices.SendEmail(subject, body, model.Email, "*****@*****.**"); result.InfoMessage = "Un email vient de vous etre envoyé avec la liste de vos annonces"; return(result); }
public async Task <bool> BookAdByAdmin([FromBody] AdRequestModel adRequest) { var result = await _adContract.BookAdByAdmin(_mapper.Map <AdRequestModel, AdRequestPOCO>(adRequest)); if (result) { return(true); } return(false); }
public ActionResult Request(AdRequestModel model) { AdRequestModel result = new AdRequestModel(); if (!_adConsistencyServices.IsEmailValid(model.Email)) { result.CanRequestAd = true; result.Email = model.Email; ModelState.AddModelError("Email", "Email incorrect"); return(View(result)); } result = _adRequestServices.RequestAds(model); return(View(result)); }