public void Do(int itemId, string callbackUrl) { var offer = offerService.GetOffer(itemId, i => i.UserProfile, i => i.UserProfile.ApplicationUser); if (offer != null) { offerService.DeactivateOffer(offer, offer.UserProfileId); offerService.SaveOffer(); string body = EmailHelpers.ActivateForm($"Здравствуйте {offer.UserProfile.Name}, ваше объявление {offer.Header} деактивировано.", "Активировать", callbackUrl).ToString(); identityMessageService.SendAsync(new IdentityMessage() { Body = body, Subject = "Ваше объявление деактивировано", Destination = offer.UserProfile.ApplicationUser.Email }).Wait(); } }
public ActionResult Deactivate(int?id = 1) { if (id != null) { var offer = _offerService.GetOffers(o => o.Id == id.Value, o => o.UserProfile).SingleOrDefault(); if (offer != null && offer.UserProfileId == User.Identity.GetUserId() && offer.State == OfferState.active) { if (offer.JobId != null) { BackgroundJob.Delete(offer.JobId); offer.JobId = null; } _offerService.DeactivateOffer(offer, User.Identity.GetUserId()); _offerService.SaveOffer(); return(View()); } } return(HttpNotFound()); }