本文整理汇总了C#中System.Web.Mvc.UrlHelper.ActionAbsolute方法的典型用法代码示例。如果您正苦于以下问题:C# UrlHelper.ActionAbsolute方法的具体用法?C# UrlHelper.ActionAbsolute怎么用?C# UrlHelper.ActionAbsolute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Mvc.UrlHelper
的用法示例。
在下文中一共展示了UrlHelper.ActionAbsolute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
public virtual ActionResult Register(MemberApiModel formData)
{
if (ModelState.IsValid)
{
var context = ModelFactory.GetUnitOfWork();
var mRepo = ModelFactory.GetRepository<IMemberRepository>(context);
var sendNewAccountMailPass = false;
var sendNewAccountMail = false;
try
{
int memberId;
var memberData = new MemberMainData
{
FirstName = formData.FirstName,
LastName = formData.LastName,
PhoneNumber = formData.PhoneNumber
};
if (formData.FacebookId != 0)
{
memberData.Avatar = this.UploadFile(string.Format(MiscHelpers.FaceBookConstants.FacebookProfilePictureUrlPattern, formData.FacebookId), MiscHelpers.ImageSize.MemberAvatar, Member.AvatarFolder);
}
if (formData.BirthDate > DateTime.MinValue)
{
memberData.BirthDate = formData.BirthDate;
}
if (!string.IsNullOrEmpty(formData.FacebookLink))
{
memberData.Facebook = formData.FacebookLink;
}
if (!string.IsNullOrEmpty(formData.PhoneNumber))
{
memberData.PhoneNumber = formData.PhoneNumber;
}
if (string.IsNullOrEmpty(formData.Password))
{
sendNewAccountMailPass = _MembershipService.TryCreateAccount(formData.Email, memberData, out memberId);
}
else
{
sendNewAccountMail = _MembershipService.TryCreateAccount(formData.Email, formData.Password, memberData, out memberId);
}
var member = mRepo.Get(memberId);
try
{
object newMemberMail = null;
if (sendNewAccountMailPass)
{
var urlHelper = new UrlHelper(ControllerContext.RequestContext);
var newMemberMailContent = string.Format(Worki.Resources.Email.FacebookRegistration.Content,
urlHelper.ActionAbsolute(MVC.Dashboard.Profil.Edit()),
member.Email,
_MembershipService.GetPassword(member.Email, null));
newMemberMail = _EmailService.PrepareMessageFromDefault(new MailAddress(member.Email, member.MemberMainData.FirstName),
Worki.Resources.Email.Activation.ActivationSubject,
WebHelper.RenderEmailToString(member.MemberMainData.FirstName, newMemberMailContent));
}
if (sendNewAccountMail)
{
var urlHelper = new UrlHelper(ControllerContext.RequestContext);
var newMemberMailContent = string.Format(Worki.Resources.Email.FacebookRegistration.ContentWithoutPass,
urlHelper.ActionAbsolute(MVC.Dashboard.Profil.Edit()));
newMemberMail = _EmailService.PrepareMessageFromDefault(new MailAddress(member.Email, member.MemberMainData.FirstName),
Worki.Resources.Email.Activation.ActivationSubject,
WebHelper.RenderEmailToString(member.MemberMainData.FirstName, newMemberMailContent));
}
context.Commit();
if (sendNewAccountMail || sendNewAccountMailPass)
{
_EmailService.Deliver(newMemberMail);
}
return new ObjectResult<AuthJson>(ModelHelper.GetAuthData(_MembershipService, formData.Email));
}
catch (Exception ex)
{
_Logger.Error(ex.Message);
context.Complete();
throw ex;
}
}
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
{
return new ObjectResult<AuthJson>(null, 400, dbEx.GetErrors());
}
catch (Exception ex)
{
_Logger.Error("Create", ex);
ModelState.AddModelError("", ex.Message);
return new ObjectResult<AuthJson>(null, 400, ex.Message);
}
}
//.........这里部分代码省略.........
示例2: Create
public virtual ActionResult Create(int id, MemberBookingFormViewModel formData)
{
var context = ModelFactory.GetUnitOfWork();
var mRepo = ModelFactory.GetRepository<IMemberRepository>(context);
var oRepo = ModelFactory.GetRepository<IOfferRepository>(context);
var memberId = WebHelper.GetIdentityId(User.Identity);
var member = mRepo.Get(memberId);
var offer = oRepo.Get(id);
if (ModelState.IsValid)
{
var sendNewAccountMail = false;
try
{
var memberData = new MemberMainData
{
FirstName = formData.FirstName,
LastName = formData.LastName,
PhoneNumber = formData.PhoneNumber,
};
sendNewAccountMail = _MembershipService.TryCreateAccount(formData.Email, memberData, out memberId);
member = mRepo.Get(memberId);
var locName = offer.Localisation.Name;
var locUrl = offer.Localisation.GetDetailFullUrl(Url);
try
{
formData.MemberBooking.MemberId = memberId;
formData.MemberBooking.OfferId = id;
formData.MemberBooking.StatusId = (int)MemberBooking.Status.Unknown;
formData.AjustBookingPeriod();
formData.MemberBooking.Price = offer.GetDefaultPrice(formData.MemberBooking.FromDate,
formData.MemberBooking.ToDate,
formData.MemberBooking.PeriodType == (int)MemberBooking.ePeriodType.SpendUnit,
(Offer.PaymentPeriod)formData.MemberBooking.TimeType,
formData.MemberBooking.TimeUnits);
//set phone number to the one from form
member.MemberMainData.PhoneNumber = formData.PhoneNumber;
member.MemberBookings.Add(formData.MemberBooking);
formData.MemberBooking.MemberBookingLogs.Add(new MemberBookingLog
{
CreatedDate = DateTime.UtcNow,
Event = "Booking Created",
EventType = (int)MemberBookingLog.BookingEvent.Creation,
LoggerId = memberId
});
formData.MemberBooking.InvoiceNumber = new InvoiceNumber();
if (!offer.Localisation.HasClient(memberId))
{
offer.Localisation.LocalisationClients.Add(new LocalisationClient { ClientId = memberId });
}
object newMemberMail = null;
if (sendNewAccountMail)
{
var urlHelper = new UrlHelper(ControllerContext.RequestContext);
var editprofilUrl = urlHelper.ActionAbsolute(MVC.Dashboard.Profil.Edit());
TagBuilder profilLink = new TagBuilder("a");
profilLink.MergeAttribute("href", editprofilUrl);
profilLink.InnerHtml = Worki.Resources.Views.Account.AccountString.EditMyProfile;
var editpasswordUrl = urlHelper.ActionAbsolute(MVC.Dashboard.Profil.Edit());
TagBuilder passwordLink = new TagBuilder("a");
passwordLink.MergeAttribute("href", editpasswordUrl);
passwordLink.InnerHtml = Worki.Resources.Views.Account.AccountString.ChangeMyPassword;
var newMemberMailContent = string.Format(Worki.Resources.Email.BookingString.BookingNewMember,
Localisation.GetOfferType(offer.Type),
formData.MemberBooking.GetStartDate(),
formData.MemberBooking.GetEndDate(),
locName,
offer.Localisation.Adress,
formData.Email,
_MembershipService.GetPassword(formData.Email, null),
passwordLink,
profilLink);
newMemberMail = _EmailService.PrepareMessageFromDefault(new MailAddress(formData.Email, formData.FirstName),
Worki.Resources.Email.BookingString.BookingNewMemberSubject,
WebHelper.RenderEmailToString(formData.FirstName, newMemberMailContent));
}
//send mail to team
var teamMailContent = string.Format(Worki.Resources.Email.BookingString.CreateBookingTeam,
string.Format("{0} {1}", member.MemberMainData.FirstName, member.MemberMainData.LastName),
formData.PhoneNumber,
member.Email,
locName,
Localisation.GetOfferType(offer.Type),
formData.MemberBooking.GetStartDate(),
formData.MemberBooking.GetEndDate(),
formData.MemberBooking.Message,
locUrl);
var teamMail = _EmailService.PrepareMessageToDefault(new MailAddress(MiscHelpers.EmailConstants.BookingMail, MiscHelpers.EmailConstants.ContactDisplayName),
Worki.Resources.Email.BookingString.BookingMailSubject,
WebHelper.RenderEmailToString(MiscHelpers.EmailConstants.ContactDisplayName, teamMailContent));
//.........这里部分代码省略.........
示例3: TransferQuotation
public virtual ActionResult TransferQuotation(int id, int page)
{
var context = ModelFactory.GetUnitOfWork();
var qRepo = ModelFactory.GetRepository<IQuotationRepository>(context);
try
{
var quotation = qRepo.Get(id);
quotation.StatusId = (int)MemberQuotation.Status.Unknown;
TempData[MiscHelpers.TempDataConstants.Info] = "La demande de devis a bien été transférée";
//send mail to quotation owner
var offer = quotation.Offer;
var localisation = offer.Localisation;
object ownerMail = null;
if (Roles.IsUserInRole(localisation.Member.Email, MiscHelpers.BackOfficeConstants.BackOfficeRole))
{
var urlHelp = new UrlHelper(ControllerContext.RequestContext);
var ownerUrl = urlHelp.ActionAbsolute(MVC.Backoffice.Localisation.QuotationDetail(quotation.Id));
TagBuilder ownerLink = new TagBuilder("a");
ownerLink.MergeAttribute("href", ownerUrl);
ownerLink.InnerHtml = Worki.Resources.Views.Account.AccountString.OwnerSpace;
var ownerMailContent = string.Format(Worki.Resources.Email.BookingString.CreateQuotationOwner,
Localisation.GetOfferType(offer.Type),
localisation.Name,
localisation.Adress,
ownerLink);
ownerMail = _EmailService.PrepareMessageFromDefault(new MailAddress(localisation.Member.Email, localisation.Member.MemberMainData.FirstName),
string.Format(Worki.Resources.Email.BookingString.CreateQuotationOwnerSubject, localisation.Name),
WebHelper.RenderEmailToString(localisation.Member.MemberMainData.FirstName, ownerMailContent));
}
else
{
//add backoffice
Roles.AddUserToRole(localisation.Member.Email, MiscHelpers.BackOfficeConstants.BackOfficeRole);
//send specific mail
var urlHelp = new UrlHelper(ControllerContext.RequestContext);
var ownerUrl = urlHelp.ActionAbsolute(MVC.Backoffice.Localisation.QuotationDetail(quotation.Id));
TagBuilder ownerLink = new TagBuilder("a");
ownerLink.MergeAttribute("href", ownerUrl);
ownerLink.InnerHtml = Worki.Resources.Views.Account.AccountString.OwnerSpace;
var ownerMailContent = string.Format(Worki.Resources.Email.BookingString.CreateQuotationAndBOOwner,
Localisation.GetOfferType(offer.Type),
localisation.Name,
localisation.Adress,
ownerUrl);
ownerMail = _EmailService.PrepareMessageFromDefault(new MailAddress(localisation.Member.Email, localisation.Member.MemberMainData.FirstName),
string.Format(Worki.Resources.Email.BookingString.CreateQuotationOwnerSubject, localisation.Name),
WebHelper.RenderEmailToString(localisation.Member.MemberMainData.FirstName, ownerMailContent));
}
context.Commit();
_EmailService.Deliver(ownerMail);
}
catch (Exception ex)
{
_Logger.Error("TransferQuotation", ex);
context.Complete();
}
return RedirectToAction(MVC.Admin.Moderation.IndexQuotation(page));
}
示例4: ConfirmBooking
public virtual ActionResult ConfirmBooking(int id, LocalisationModel<MemberBooking> memberBooking)
{
var memberId = WebHelper.GetIdentityId(User.Identity);
var context = ModelFactory.GetUnitOfWork();
var bRepo = ModelFactory.GetRepository<IBookingRepository>(context);
if (ModelState.IsValid)
{
try
{
var booking = bRepo.Get(id);
TryUpdateModel(booking, "InnerModel");
booking.StatusId = (int)MemberBooking.Status.Accepted;
booking.MemberBookingLogs.Add(new MemberBookingLog
{
CreatedDate = DateTime.UtcNow,
Event = "Booking Confirmed",
EventType = (int)MemberBookingLog.BookingEvent.Approval,
LoggerId = memberId
});
//send mail to owner
//useless
//send mail to client
var urlHelp = new UrlHelper(ControllerContext.RequestContext);
var userUrl = urlHelp.ActionAbsolute(MVC.Dashboard.Home.Booking());
TagBuilder userLink = new TagBuilder("a");
userLink.MergeAttribute("href", userUrl);
userLink.InnerHtml = Worki.Resources.Views.Shared.SharedString.SpaceUser;
var clientMailContent = string.Format(Worki.Resources.Email.BookingString.AcceptBookingClient,
Localisation.GetOfferType(booking.Offer.Type),
booking.GetStartDate(),
booking.GetEndDate(),
booking.Offer.Localisation.Name,
booking.Offer.Localisation.Adress + ", " + booking.Offer.Localisation.PostalCode + " " + booking.Offer.Localisation.City,
booking.Price,
userLink);
var clientMail = _EmailService.PrepareMessageFromDefault(new MailAddress( booking.Client.Email, booking.Client.MemberMainData.FirstName),
Worki.Resources.Email.BookingString.AcceptBookingClientSubject,
WebHelper.RenderEmailToString( booking.Client.MemberMainData.FirstName, clientMailContent));
context.Commit();
_EmailService.Deliver(clientMail);
TempData[MiscHelpers.TempDataConstants.Info] = Worki.Resources.Views.Booking.BookingString.BookingAccepted;
return RedirectToAction(MVC.Backoffice.Localisation.BookingDetail(booking.Id));
}
catch (Exception ex)
{
_Logger.Error("ConfirmBooking", ex);
context.Complete();
}
}
return View(memberBooking);
}
示例5: ResetPassword
public virtual ActionResult ResetPassword(ResetPasswordModel model)
{
if (ModelState.IsValid)
{
try
{
if (_MembershipService.ResetPassword(model.EMail))
{
//send mail to activate the account
var context = ModelFactory.GetUnitOfWork();
var mRepo = ModelFactory.GetRepository<IMemberRepository>(context);
var member = mRepo.GetMember(model.EMail);
try
{
var urlHelper = new UrlHelper(ControllerContext.RequestContext);
var profilLink = urlHelper.ActionAbsolute(MVC.Dashboard.Home.Index());
TagBuilder link = new TagBuilder("a");
link.MergeAttribute("href", profilLink);
link.InnerHtml = Worki.Resources.Email.ResetPassword.ResetPasswordLink;
var resetMailContent = string.Format(Worki.Resources.Email.ResetPassword.ResetPasswordContent, member.Email, _MembershipService.GetPassword(member.Email, null), link.ToString()); ;
var resetMail = _EmailService.PrepareMessageFromDefault(new MailAddress(member.Email, member.MemberMainData.FirstName),
Worki.Resources.Email.ResetPassword.ResetPasswordSubject,
WebHelper.RenderEmailToString(member.MemberMainData.FirstName, resetMailContent));
_EmailService.Deliver(resetMail);
}
catch (Exception ex)
{
_Logger.Error("error", ex);
}
TempData[MiscHelpers.TempDataConstants.Info] = Worki.Resources.Views.Account.AccountString.PasswordHaveBeenChanged;
return RedirectToAction(MVC.Home.Index());
}
else
{
ModelState.AddModelError("", Worki.Resources.Validation.ValidationString.MailDoNotMatch);
}
}
catch (Member.ValidationException ex)
{
_Logger.Error("LogOn", ex);
ModelState.AddModelError("", ex.Message);
}
catch (Exception ex)
{
_Logger.Error("LogOn", ex);
ModelState.AddModelError("", Worki.Resources.Validation.ValidationString.MailDoNotMatch);
}
}
return View(MVC.Account.Views.ResetPassword, model);
}
示例6: SendMailToOldOffice
public virtual ActionResult SendMailToOldOffice()
{
var context = ModelFactory.GetUnitOfWork();
var lRepo = ModelFactory.GetRepository<ILocalisationRepository>(context);
var message = "";
var tenDaysAgo = DateTime.UtcNow.AddDays(-10);
//var surveyLink = "http://freeonlinesurveys.com/app/rendersurvey.asp?sid=k6ayan6kqlq5jzg103522";
try
{
var oldSharedOffices = lRepo.GetMany(l => l.TypeValue == (int)LocalisationType.SharedOffice &&
l.CountryId == "FR" &&
l.MemberEditions.FirstOrDefault(me => me.ModificationType == (int)EditionType.Creation).ModificationDate < tenDaysAgo &&
l.MainLocalisation.IsOffline == false);
int count = 1;
foreach (var item in oldSharedOffices)
{
if (!item.HasOwner())
continue;
var urlHelp = new UrlHelper(ControllerContext.RequestContext);
var offlineAndRedirectUrl = urlHelp.ActionAbsolute(MVC.Localisation.PutOfflineAndRedirect(item.ID, null));
offlineAndRedirectUrl = offlineAndRedirectUrl.Replace("localhost:15157", "www.eworky.com");
TagBuilder offlineAndRedirectLink = new TagBuilder("a");
offlineAndRedirectLink.MergeAttribute("href", offlineAndRedirectUrl);
offlineAndRedirectLink.InnerHtml = "cliquer sur ce lien pour la mettre hors ligne";
var editUrl = urlHelp.ActionAbsolute(MVC.Localisation.Edit(item.ID));
editUrl = editUrl.Replace("localhost:15157", "www.eworky.com");
TagBuilder editLink = new TagBuilder("a");
editLink.MergeAttribute("href", editUrl);
editLink.InnerHtml = "compléter au mieux votre fiche avec les prix des différentes offres et des photos";
var content = @"vous avez ajouté une annonce de bureau à partager sur eWorky.
Si vous avez loué votre bureau et que votre annonce n'est plus d'actualité, merci de {0}.
Si vos bureaux sont toujours disponibles ou que vous les louez régulièrement sur du court terme, nous vous invitons à {1}. Les annonces les mieux complétées, avec de belles photos et un prix attractif pour la localisation sont celles qui reçoivent le plus de demandes.
";
var oldOfficeMailContent = string.Format(content, offlineAndRedirectLink, editLink);
var oldOfficeMail = _EmailService.PrepareMessageFromDefault(new MailAddress(item.Member.Email,item.Member.MemberMainData.FirstName),
string.Format("Votre annonce {0} sur eWorky", item.Name),
WebHelper.RenderEmailToString(item.Member.MemberMainData.FirstName, oldOfficeMailContent));
_EmailService.Deliver(oldOfficeMail);
count++;
message += item.ID.ToString();
message += "\n";
if (WebHelper.IsDebug())
break;
}
message += string.Format("\nsending of {0} mails", count);
}
catch (Exception ex)
{
_Logger.Error("SendMailToOldOffice", ex);
return Content(ex.Message);
}
return Content(MiscHelpers.Nl2Br(message));
}
示例7: AddOwnerPlace
public virtual ActionResult AddOwnerPlace(OwnerLocalisationModel model)
{
var context = ModelFactory.GetUnitOfWork();
var mRepo = ModelFactory.GetRepository<IMemberRepository>(context);
var lRepo = ModelFactory.GetRepository<ILocalisationRepository>(context);
if (ModelState.IsValid)
{
MemberMainData maindata = new MemberMainData();
maindata.FirstName = model.Firstname;
maindata.LastName = model.Name;
maindata.PhoneNumber = model.PhoneNumber;
try
{
var loc = lRepo.Get(model.LocalisationId);
if (loc == null)
{
throw new Exception(Worki.Resources.Models.Localisation.Localisation.LocalisationError);
}
if (loc.OwnerID != 1)
{
throw new Exception(Worki.Resources.Models.Localisation.Localisation.OwnerAllreadyExist);
}
int memberId;
bool sendNewAccountMail = _MembershipService.TryCreateAccount(model.Email.ToString(), maindata, out memberId, false);
if (memberId == 0)
{
throw new Exception("Utilisateur non crée");
}
var member = mRepo.Get(memberId);
member.MemberMainData.BOStatus = (int)eBOStatus.Done;
Roles.AddUserToRole(member.Username, MiscHelpers.BackOfficeConstants.BackOfficeRole);
loc.OwnerID = memberId;
context.Commit();
if (sendNewAccountMail)
{
var urlHelper = new UrlHelper(ControllerContext.RequestContext);
var activationLink = urlHelper.ActionAbsolute(MVC.Account.Activate(member.Email, member.EmailKey));
TagBuilder link = new TagBuilder("a");
link.MergeAttribute("href", activationLink);
link.InnerHtml = activationLink;
var ownerMailContent = string.Format(Worki.Resources.Email.Common.AdminOwnershipAndAccount,
loc.Name,
activationLink.ToString(),
loc.GetDetailFullUrl(Url),
model.Email,
_MembershipService.GetPassword(model.Email, null));
var ownerMail = _EmailService.PrepareMessageFromDefault(new MailAddress(model.Email, model.Firstname),
string.Format(Worki.Resources.Email.Common.OwnershipSubject, loc.Name),
WebHelper.RenderEmailToString(model.Firstname, ownerMailContent));
_EmailService.Deliver(ownerMail);
}
else
{
var urlHelper = new UrlHelper(ControllerContext.RequestContext);
var boLink = urlHelper.ActionAbsolute(MVC.Backoffice.Localisation.Index(loc.ID));
TagBuilder link = new TagBuilder("a");
link.MergeAttribute("href", boLink);
link.InnerHtml = Worki.Resources.Views.Account.AccountString.OwnerSpace;
var ownerMailContent = string.Format(Worki.Resources.Email.Common.AdminOwnership,
loc.Name,
boLink.ToString());
var ownerMail = _EmailService.PrepareMessageFromDefault(new MailAddress(model.Email, model.Firstname),
string.Format(Worki.Resources.Email.Common.OwnershipSubject, loc.Name),
WebHelper.RenderEmailToString(model.Firstname, ownerMailContent));
_EmailService.Deliver(ownerMail);
}
return RedirectToAction(MVC.Admin.Member.IndexOwner());
}
catch (Exception ex)
{
_Logger.Error("", ex);
ModelState.AddModelError("", ex.Message);
context.Complete();
}
}
return View(model);
}
示例8: FacebookOAuth
public virtual ActionResult FacebookOAuth(string code, string state)
{
FacebookOAuthResult oauthResult;
if (FacebookOAuthResult.TryParse(Request.Url, out oauthResult))
{
if (oauthResult.IsSuccess)
{
string redirectUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Url.Action(this.FacebookOAuth());
var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current);
oAuthClient.RedirectUri = new Uri(redirectUrl);
dynamic tokenResult = oAuthClient.ExchangeCodeForAccessToken(code);
string accessToken = tokenResult.access_token;
//DateTime expiresOn = DateTime.MaxValue;
//if (tokenResult.ContainsKey("expires"))
//{
// DateTimeConvertor.FromUnixTime(tokenResult.expires);
//}
FacebookClient fbClient = new FacebookClient(accessToken);
dynamic me = fbClient.Get("me?fields=id,name,email,first_name,last_name,link,birthday");
long facebookId = Convert.ToInt64(me.id);
string faceBookEmailAddress = ((string)me.email).ToString();
string faceBookFirstName = ((string)me.first_name).ToString();
string faceBookLastName = ((string)me.last_name).ToString();
string faceBookLink = ((string)me.link).ToString();
var facebookBirthday = DateTime.Parse((string)me.birthday, new System.Globalization.CultureInfo("en"));
var context = ModelFactory.GetUnitOfWork();
var mRepo = ModelFactory.GetRepository<IMemberRepository>(context);
var member = mRepo.GetMember(faceBookEmailAddress);
if (member == null)
{
bool created = false;
int memberId = 0;
try
{
var uploadedFileName = this.UploadFile(string.Format(MiscHelpers.FaceBookConstants.FacebookProfilePictureUrlPattern, facebookId), MiscHelpers.ImageSize.MemberAvatar, Member.AvatarFolder);
var memberData = new MemberMainData
{
Avatar = uploadedFileName,
Facebook = faceBookLink,//string.Format(MiscHelpers.FaceBookConstants.FacebookProfileViewPattern, facebookId, facebookId),
FirstName = faceBookFirstName,
LastName = faceBookLastName,
BirthDate = facebookBirthday
};
created = _MembershipService.TryCreateAccount(faceBookEmailAddress, memberData, out memberId);
}
catch (Exception ex)
{
_Logger.Error(ex.Message);
}
if (created)
{
context = ModelFactory.GetUnitOfWork();
mRepo = ModelFactory.GetRepository<IMemberRepository>(context);
member = mRepo.Get(memberId);
var urlHelper = new UrlHelper(ControllerContext.RequestContext);
// Send mail
try
{
var facebookMailContent = string.Format(Worki.Resources.Email.FacebookRegistration.Content,
urlHelper.ActionAbsolute(MVC.Dashboard.Profil.Edit()),
member.Email,
_MembershipService.GetPassword(member.Email, null));
var facebookMail = _EmailService.PrepareMessageFromDefault(new MailAddress(member.Email, member.MemberMainData.FirstName),
Worki.Resources.Email.Activation.ActivationSubject,
WebHelper.RenderEmailToString(member.MemberMainData.FirstName, facebookMailContent));
_EmailService.Deliver(facebookMail);
}
catch (Exception ex)
{
_Logger.Error(ex.Message);
}
TempData[MiscHelpers.TempDataConstants.Info] = Worki.Resources.Views.Account.InscriptionString.RegisterEworky;
}
else
{
return RedirectToAction(MVC.Home.Index());
}
}
var userData = member.GetUserData();
_FormsService.SignIn(member.Email, userData, /*model.RememberMe*/true, ControllerContext.HttpContext.Response);
if (Url.IsLocalUrl(state))
{
return Redirect(state);
}
else
{
return RedirectToAction(MVC.Home.Index());
//.........这里部分代码省略.........
示例9: Add
public virtual ActionResult Add(int id, LocalisationModel<ProfilFormViewModel> formData)
{
//the other page that use the same models don't require the phonenumber, so we check only in this method if it's required
if (String.IsNullOrEmpty(formData.InnerModel.Member.MemberMainData.PhoneNumber))
{
ModelState.AddModelError("InnerModel.Member.MemberMainData.PhoneNumber", string.Format(Worki.Resources.Validation.ValidationString.Required, Worki.Resources.Models.Profile.Profile.PhoneNumber));
}
if (ModelState.IsValid)
{
var memberId = WebHelper.GetIdentityId(User.Identity);
var sendNewAccountMail = false;
try
{
var clientId = 0;
sendNewAccountMail = _MembershipService.TryCreateAccount(formData.InnerModel.Member.Email, formData.InnerModel.Member.MemberMainData, out clientId);
var context = ModelFactory.GetUnitOfWork();
var mRepo = ModelFactory.GetRepository<IMemberRepository>(context);
var lRepo = ModelFactory.GetRepository<ILocalisationRepository>(context);
var localisation = lRepo.Get(id);
var client = mRepo.Get(clientId);
if (localisation.HasClient(clientId))
{
throw new Exception(Worki.Resources.Views.BackOffice.BackOfficeString.ClientAlreadyExists);
}
try
{
localisation.LocalisationClients.Add(new LocalisationClient { ClientId = clientId });
TryUpdateModel(client, "InnerModel.Member");
object newMemberMail = null;
if (sendNewAccountMail)
{
var urlHelper = new UrlHelper(ControllerContext.RequestContext);
var editprofilUrl = urlHelper.ActionAbsolute(MVC.Dashboard.Profil.Edit());
TagBuilder profilLink = new TagBuilder("a");
profilLink.MergeAttribute("href", editprofilUrl);
profilLink.InnerHtml = Worki.Resources.Views.Account.AccountString.EditMyProfile;
var editpasswordUrl = urlHelper.ActionAbsolute(MVC.Dashboard.Profil.Edit());
TagBuilder passwordLink = new TagBuilder("a");
passwordLink.MergeAttribute("href", editpasswordUrl);
passwordLink.InnerHtml = Worki.Resources.Views.Account.AccountString.ChangeMyPassword;
var newMemberMailContent = string.Format(Worki.Resources.Email.BookingString.ClientCreationAccount,
client.Email,
_MembershipService.GetPassword(client.Email, null),
passwordLink,
profilLink);
newMemberMail = _EmailService.PrepareMessageFromDefault(new MailAddress(client.Email, client.MemberMainData.FirstName),
Worki.Resources.Email.BookingString.ClientCreationAccountSubject,
WebHelper.RenderEmailToString(client.MemberMainData.FirstName, newMemberMailContent));
}
context.Commit();
if (sendNewAccountMail)
{
_EmailService.Deliver(newMemberMail);
}
}
catch (Exception ex)
{
_Logger.Error(ex.Message);
context.Complete();
throw ex;
}
TempData[MiscHelpers.TempDataConstants.Info] = Worki.Resources.Views.BackOffice.BackOfficeString.ClientAdded;
return RedirectToAction(MVC.Backoffice.Client.LocalisationList(id, null));
}
catch (Exception ex)
{
_Logger.Error("Add", ex);
ModelState.AddModelError("", ex.Message);
}
}
return View(formData);
}
示例10: SetBackoffice
public virtual ActionResult SetBackoffice(int id)
{
var context = ModelFactory.GetUnitOfWork();
var mRepo = ModelFactory.GetRepository<IMemberRepository>(context);
var member = mRepo.Get(id);
try
{
var roleToGive = !Roles.IsUserInRole(member.Username, MiscHelpers.BackOfficeConstants.BackOfficeRole);
if (roleToGive)
{
member.MemberMainData.BOStatus = (int)eBOStatus.Done;
Roles.AddUserToRole(member.Username, MiscHelpers.BackOfficeConstants.BackOfficeRole);
}
else
{
member.MemberMainData.BOStatus = (int)eBOStatus.None;
Roles.RemoveUserFromRole(member.Username, MiscHelpers.BackOfficeConstants.BackOfficeRole);
}
context.Commit();
//email to tell bo has been given
if (roleToGive)
{
var urlHelper = new UrlHelper(ControllerContext.RequestContext);
var boHomeUrl = urlHelper.ActionAbsolute(MVC.Backoffice.Home.Index());
TagBuilder boHomeLink = new TagBuilder("a");
boHomeLink.MergeAttribute("href", boHomeUrl);
boHomeLink.InnerHtml = Worki.Resources.Email.Activation.BOLink;
var confirmationMailContent = string.Format(Worki.Resources.Email.Activation.BOConfirmContent, boHomeLink);
var confirmationMail = _EmailService.PrepareMessageFromDefault(new MailAddress(member.Email, member.GetDisplayName()),
Worki.Resources.Email.Activation.BOConfirmSubject,
WebHelper.RenderEmailToString(member.GetDisplayName(), confirmationMailContent));
_EmailService.Deliver(confirmationMail);
}
}
catch (Exception ex)
{
context.Complete();
_Logger.Error("SetBackoffice", ex);
}
return RedirectToAction(MVC.Admin.Member.IndexOwner());
}
示例11: InternalCreateBooking
MemberBooking InternalCreateBooking(CreateBookingModel createBookingModel)
{
var context = ModelFactory.GetUnitOfWork();
var oRepo = ModelFactory.GetRepository<IOfferRepository>(context);
var memberId = WebHelper.GetIdentityId(User.Identity);
var offer = oRepo.Get(createBookingModel.Booking.OfferId);
try
{
createBookingModel.Booking.MemberBookingLogs.Add(new MemberBookingLog
{
CreatedDate = DateTime.UtcNow,
EventType = (int)MemberBookingLog.BookingEvent.Creation,
Event = "Booking Created From Calandar",
}
);
createBookingModel.Booking.InvoiceNumber = new InvoiceNumber();
if (createBookingModel.Booking.Paid)
{
createBookingModel.Booking.MemberBookingLogs.Add(new MemberBookingLog
{
CreatedDate = DateTime.UtcNow,
Event = "Payment completed",
EventType = (int)MemberBookingLog.BookingEvent.Payment,
LoggerId = memberId
});
}
offer.MemberBookings.Add(createBookingModel.Booking);
context.Commit();
var newContext = ModelFactory.GetUnitOfWork();
var bRepo = ModelFactory.GetRepository<IBookingRepository>(newContext);
var booking = bRepo.Get(createBookingModel.Booking.Id);
//send mail to client
var urlHelper = new UrlHelper(ControllerContext.RequestContext);
var dashboardUrl = urlHelper.ActionAbsolute(MVC.Dashboard.Home.Index());
TagBuilder dashboardLink = new TagBuilder("a");
dashboardLink.MergeAttribute("href", dashboardUrl);
dashboardLink.InnerHtml = dashboardUrl;
var localisationUrl = booking.Offer.Localisation.GetDetailFullUrl(Url);
TagBuilder localisationLink = new TagBuilder("a");
localisationLink.MergeAttribute("href", localisationUrl);
localisationLink.InnerHtml = localisationUrl;
var clientMailContent = string.Format(Worki.Resources.Email.BookingString.CalandarBookingCreation,
Localisation.GetOfferType(booking.Offer.Type),
booking.Offer.Localisation.Name,
booking.GetStartDate(),
booking.GetEndDate(),
dashboardLink,
booking.Price,
localisationLink);
var clientMail = _EmailService.PrepareMessageFromDefault(new MailAddress(booking.Client.Email, booking.Client.MemberMainData.FirstName),
string.Format(Worki.Resources.Email.BookingString.CalandarBookingCreationSubject, booking.Offer.Localisation.Name),
WebHelper.RenderEmailToString(booking.Client.MemberMainData.FirstName, clientMailContent));
_EmailService.Deliver(clientMail);
return booking;
}
catch (Exception ex)
{
_Logger.Error("CreateEvent", ex);
context.Complete();
throw new ModelStateException(ModelState);
}
}
示例12: ResizeEvent
public virtual ActionResult ResizeEvent(int id, int dayDelta, int minuteDelta)
{
var context = ModelFactory.GetUnitOfWork();
var bRepo = ModelFactory.GetRepository<IBookingRepository>(context);
var booking = bRepo.Get(id);
if (booking != null)
{
var newToDate = booking.ToDate.AddDays(dayDelta).AddMinutes(minuteDelta);
if (!booking.CanModify(newToDate))
throw new ModelStateException(ModelState);
try
{
booking.ToDate = booking.ToDate.AddDays(dayDelta).AddMinutes(minuteDelta);
//send mail to booking client
var urlHelper = new UrlHelper(ControllerContext.RequestContext);
var dashboardUrl = urlHelper.ActionAbsolute(MVC.Dashboard.Home.Index());
TagBuilder dashboardLink = new TagBuilder("a");
dashboardLink.MergeAttribute("href", dashboardUrl);
dashboardLink.InnerHtml = dashboardUrl;
var localisationUrl = booking.Offer.Localisation.GetDetailFullUrl(Url);
TagBuilder localisationLink = new TagBuilder("a");
localisationLink.MergeAttribute("href", localisationUrl);
localisationLink.InnerHtml = localisationUrl;
var clientMailContent = string.Format(Worki.Resources.Email.BookingString.CalandarBookingModification,
booking.Offer.Localisation.Name,
booking.GetStartDate(),
booking.GetEndDate(),
dashboardLink,
localisationLink);
var clientMail = _EmailService.PrepareMessageFromDefault(new MailAddress(booking.Client.Email, booking.Client.MemberMainData.FirstName),
string.Format(Worki.Resources.Email.BookingString.CalandarBookingModificationSubject, booking.Offer.Localisation.Name),
WebHelper.RenderEmailToString(booking.Client.MemberMainData.FirstName, clientMailContent));
context.Commit();
_EmailService.Deliver(clientMail);
return Json("Resize success");
}
catch (Exception ex)
{
_Logger.Error("ResizeEvent", ex);
context.Complete();
throw new ModelStateException(ModelState);
}
}
else
{
throw new ModelStateException(ModelState);
}
}
示例13: EditBooking
public virtual ActionResult EditBooking(int id, LocalisationModel<CreateBookingModel> createBookingModel)
{
var context = ModelFactory.GetUnitOfWork();
var memberId = WebHelper.GetIdentityId(User.Identity);
var bRepo = ModelFactory.GetRepository<IBookingRepository>(context);
var booking = bRepo.Get(id);
if (ModelState.IsValid)
{
try
{
TryUpdateModel(booking, "InnerModel.Booking");
if (booking.Paid)
{
booking.MemberBookingLogs.Add(new MemberBookingLog
{
CreatedDate = DateTime.UtcNow,
Event = "Payment completed",
EventType = (int)MemberBookingLog.BookingEvent.Payment,
LoggerId = memberId
});
}
object clientMail = null;
if (booking.StatusId == (int)MemberBooking.Status.Accepted)
{
//send mail to client
var urlHelp = new UrlHelper(ControllerContext.RequestContext);
var userUrl = urlHelp.ActionAbsolute(MVC.Dashboard.Home.Booking());
TagBuilder userLink = new TagBuilder("a");
userLink.MergeAttribute("href", userUrl);
userLink.InnerHtml = Worki.Resources.Views.Shared.SharedString.SpaceUser;
var clientMailContent = string.Format(Worki.Resources.Email.BookingString.AcceptBookingClient,
Localisation.GetOfferType(booking.Offer.Type),
booking.GetStartDate(),
booking.GetEndDate(),
booking.Offer.Localisation.Name,
booking.Offer.Localisation.Adress + ", " + booking.Offer.Localisation.PostalCode + " " + booking.Offer.Localisation.City,
booking.Price,
userLink);
clientMail = _EmailService.PrepareMessageFromDefault(new MailAddress(booking.Client.Email, booking.Client.MemberMainData.FirstName),
Worki.Resources.Email.BookingString.AcceptBookingClientSubject,
WebHelper.RenderEmailToString(booking.Client.MemberMainData.FirstName, clientMailContent));
}
context.Commit();
if (booking.StatusId == (int)MemberBooking.Status.Accepted)
{
_EmailService.Deliver(clientMail);
}
var newContext = ModelFactory.GetUnitOfWork();
var newRepo = ModelFactory.GetRepository<IBookingRepository>(newContext);
var newBooking = newRepo.Get(id);
return RedirectToAction(MVC.Backoffice.Schedule.OfferSchedule(newBooking.Offer.LocalisationId, newBooking.OfferId));
}
catch (Exception ex)
{
_Logger.Error("CreateEvent", ex);
context.Complete();
}
}
createBookingModel.InnerModel.InitSelectLists(booking.Offer.Localisation);
return View(MVC.Backoffice.Schedule.Views.CreateBooking, createBookingModel);
}
示例14: GenerateAbsoluteExampleUrl
private static TagBuilder GenerateAbsoluteExampleUrl(string action, object routeData, UrlHelper url)
{
string address = url.ActionAbsolute(action, "Log", routeData);
TagBuilder tagBuilder = new TagBuilder("a");
//generate a link tag
tagBuilder.Attributes.Add("href", address);
tagBuilder.SetInnerText(address);
return tagBuilder;
}
示例15: CreateQuotation
/// <summary>
/// private method to create quoation and send corresponding mails
/// </summary>
/// <param name="memberId">the client</param>
/// <param name="offerId">the offer</param>
/// <param name="formData">quotation data</param>
void CreateQuotation(int memberId, int offerId, MemberQuotationFormViewModel formData)
{
var context = ModelFactory.GetUnitOfWork();
var mRepo = ModelFactory.GetRepository<IMemberRepository>(context);
var oRepo = ModelFactory.GetRepository<IOfferRepository>(context);
var lRepo = ModelFactory.GetRepository<ILocalisationRepository>(context);
var member = mRepo.Get(memberId);
var offer = oRepo.Get(offerId);
var sendNewAccountMail = false;
try
{
var memberData = new MemberMainData
{
FirstName = formData.FirstName,
LastName = formData.LastName,
PhoneNumber = formData.PhoneNumber,
};
sendNewAccountMail = _MembershipService.TryCreateAccount(formData.Email, memberData, out memberId);
member = mRepo.Get(memberId);
var locName = offer.Localisation.Name;
var locUrl = offer.Localisation.GetDetailFullUrl(Url);
var localisation = lRepo.Get(offer.LocalisationId);
var hasOwner = localisation.HasOwner();
if (hasOwner)
{
formData.MemberQuotation.MemberId = memberId;
formData.MemberQuotation.OfferId = offerId;
formData.MemberQuotation.StatusId = (localisation.DirectlyReceiveQuotation == true) ? (int)MemberQuotation.Status.Unknown : (int)MemberQuotation.Status.Pending;
member.MemberQuotations.Add(formData.MemberQuotation);
formData.MemberQuotation.MemberQuotationLogs.Add(new MemberQuotationLog
{
CreatedDate = DateTime.UtcNow,
Event = "Quotation Created",
EventType = (int)MemberQuotationLog.QuotationEvent.Creation,
LoggerId = memberId
});
}
//set phone number to the one from form
member.MemberMainData.PhoneNumber = formData.PhoneNumber;
dynamic newMemberMail = null;
if (sendNewAccountMail)
{
var urlHelper = new UrlHelper(ControllerContext.RequestContext);
var editpasswordUrl = urlHelper.ActionAbsolute(MVC.Dashboard.Profil.ChangePassword());
TagBuilder editpasswordLink = new TagBuilder("a");
editpasswordLink.MergeAttribute("href", editpasswordUrl);
editpasswordLink.InnerHtml = Worki.Resources.Views.Account.AccountString.ChangeMyPassword;
var editprofilUrl = urlHelper.ActionAbsolute(MVC.Dashboard.Profil.Edit());
TagBuilder editprofilLink = new TagBuilder("a");
editprofilLink.MergeAttribute("href", editprofilUrl);
editprofilLink.InnerHtml = Worki.Resources.Views.Account.AccountString.EditMyProfile;
var newMemberMailContent = string.Format(Worki.Resources.Email.BookingString.QuotationNewMemberBody,
Localisation.GetOfferType(offer.Type), //0
offer.Localisation.Name, //1
offer.Localisation.Adress, //2
formData.Email, //3
_MembershipService.GetPassword(formData.Email, null), //4
editpasswordLink, //5
editprofilLink); //6;
newMemberMail = _EmailService.PrepareMessageFromDefault(new MailAddress(formData.Email, formData.FirstName),
Worki.Resources.Email.BookingString.QuotationNewMemberSubject,
WebHelper.RenderEmailToString(formData.FirstName, newMemberMailContent));
}
//send mail to team
var teamMailContent = string.Format(Worki.Resources.Email.BookingString.QuotationMailBody,
string.Format("{0} {1}", member.MemberMainData.FirstName, member.MemberMainData.LastName), //0
formData.PhoneNumber, //1
member.Email, //2
locName, //3
Localisation.GetOfferType(offer.Type), //4
formData.MemberQuotation.Message, //5
locUrl); //6
var teamMail = _EmailService.PrepareMessageFromDefault(new MailAddress(MiscHelpers.EmailConstants.BookingMail, MiscHelpers.EmailConstants.ContactDisplayName),
hasOwner ? Worki.Resources.Email.BookingString.QuotationMailSubject : Worki.Resources.Email.BookingString.QuotationMailSubject + " (sans gérant)",
WebHelper.RenderEmailToString(MiscHelpers.EmailConstants.ContactDisplayName, teamMailContent));
//send mail to quoation client
var clientMailContent = string.Format(Worki.Resources.Email.BookingString.CreateQuotationClient,
Localisation.GetOfferType(offer.Type), //0
locName, //1
offer.Localisation.Adress); //2
var clientMail = _EmailService.PrepareMessageFromDefault(new MailAddress(member.Email, member.MemberMainData.FirstName),
Worki.Resources.Email.BookingString.CreateQuotationClientSubject,
//.........这里部分代码省略.........