public static string GetMediaImageUrl(this IPublishedContent content, string property) { var helper = new UmbracoHelper(UmbracoContext.Current); var url = content.GetPropertyValue <int>(property) != 0 ? helper.TypedMedia(content.GetPropertyValue <int>(property)).Url : string.Empty; return(PauHelper.MakeImageFullPath(url)); }
public static string CoaleseFieldRecursively(this IPublishedContent currentNode, string property, bool recursive = false) { if (currentNode == null) { return(""); } var content = currentNode.GetPropertyValue <string>(property, recursive); return(PauHelper.MakeContentImageFullPath(content)); }
public HttpResponseMessage CreateOrUpdateLumixUserProfile([FromBody] LumixPromotionUserProfileModel model) { try { if (ModelState.IsValid) { var arr = model.Email.Split('@'); string email = string.Empty; if (arr.Length == 2) { email = string.Format("{0}_{1}@{2}", arr[0], model.Id, arr[1]); model.Email = email; } var userInfo = _eloquaService.GetLumixContactProfiles(model.Id); if (userInfo != null && userInfo.Email != model.Email) { _eloquaService.ChangeEmailAddress(userInfo.EloquaContactId, userInfo.Email, model.Email); } var contactDetails = PauHelper.MapLumixAccountModelToContactDetailEntity(model); _eloquaService.CreateOrUpdateContact(contactDetails); return(Request.CreateResponse(HttpStatusCode.OK, new ResponseDTO { Success = true, StatusCode = 200, Message = WellknownResponseMessages.Success })); } return(Request.CreateResponse(HttpStatusCode.BadRequest, new ResponseDTO { Success = false, StatusCode = 400, Message = WellknownResponseMessages.Falied, Errors = ModelState.AllErrors() })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ResponseDTO { Success = false, StatusCode = 500, Message = WellknownResponseMessages.Falied, Errors = new List <string> { ex.Message + "\r\n" + ex.StackTrace } })); } }
public HttpResponseMessage GetLumixUserProfile(string id) { Regex regex = new Regex("^[0-9]{1,11}$"); if (string.IsNullOrEmpty(id) || !regex.IsMatch(id)) { ModelState.AddModelError("LumixUserProfile", WellknownResponseMessages.ContactIdRequired); return(Request.CreateResponse(HttpStatusCode.BadRequest, new LumixUserProfileResponseDTO { Success = false, StatusCode = 400, Message = WellknownResponseMessages.Falied, Errors = ModelState.AllErrors() })); } try { var userInfo = _eloquaService.GetLumixContactProfiles(id); if (userInfo == null) { ModelState.AddModelError("LumixUserProfile", string.Format(WellknownResponseMessages.AccountNotValid, id)); return(Request.CreateResponse(HttpStatusCode.BadRequest, new LumixUserProfileResponseDTO { Success = false, StatusCode = 400, Message = WellknownResponseMessages.Falied, Errors = ModelState.AllErrors() })); } var response = PauHelper.MapContactDetailEntityToLumixAccountModel(userInfo); return(Request.CreateResponse(HttpStatusCode.OK, new LumixUserProfileResponseDTO { Success = true, StatusCode = 200, Message = WellknownResponseMessages.Success, UserInfo = response })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, new LumixUserProfileResponseDTO { Success = false, StatusCode = 500, Message = WellknownResponseMessages.Falied, Errors = new List <string> { ex.Message + "\r\n" + ex.StackTrace } })); } }
public HttpResponseMessage GetUserProfile(string emailAddress) { try { var userInfo = _eloquaService.GetContactDetailsByEmail(emailAddress); if (userInfo == null) { ModelState.AddModelError("EmailAddress", WellknownResponseMessages.EmailNotExisted); return(Request.CreateResponse(HttpStatusCode.BadRequest, new UserProfileResponseDTO { Success = false, StatusCode = 400, Message = WellknownResponseMessages.Falied, Errors = ModelState.AllErrors() })); } if (!ValidateIdentity(userInfo.EloquaContactId)) { ModelState.AddModelError("InvalidRequest", WellknownResponseMessages.InvalidRequest); return(Request.CreateResponse(HttpStatusCode.BadRequest, new UserProfileResponseDTO { Success = false, StatusCode = 400, Message = WellknownResponseMessages.Falied, Errors = ModelState.AllErrors() })); } var response = PauHelper.MapContactDetailToRegisterAccountModel(userInfo); return(Request.CreateResponse(HttpStatusCode.OK, new UserProfileResponseDTO { Success = true, StatusCode = 200, Message = WellknownResponseMessages.Success, UserInfo = response })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, new UserProfileResponseDTO { Success = false, StatusCode = 500, Message = WellknownResponseMessages.Falied, Errors = new List <string> { ex.Message + "\r\n" + ex.StackTrace } })); } }
public HttpResponseMessage Register([FromBody] RegisterAccountModel model) { try { if (ModelState.ContainsKey("model.DateOfBirth") && ModelState["model.DateOfBirth"].Errors.Any(x => x.Exception != null)) { ModelState.AddModelError("DateOfBirth", WellknownResponseMessages.InvalidBirthDateFormat); } if (ModelState.IsValid) { if (string.IsNullOrEmpty(model.PAUMemberSource)) { model.PAUMemberSource = PauHelper.PromotionSite; } var contactDetails = PauHelper.MapRegisterAccountModelToContactDetailEntity(model); contactDetails.PasswordResetGuid = Guid.NewGuid().ToString(); _eloquaService.CreateOrUpdateContact(contactDetails); return(Request.CreateResponse(HttpStatusCode.OK, new ResponseDTO { Success = true, StatusCode = 200, Message = WellknownResponseMessages.Success })); } return(Request.CreateResponse(HttpStatusCode.BadRequest, new ResponseDTO { Success = false, StatusCode = 400, Message = WellknownResponseMessages.Falied, Errors = ModelState.AllErrors() })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ResponseDTO { Success = false, StatusCode = 500, Message = WellknownResponseMessages.Falied, Errors = new List <string> { ex.Message + "\r\n" + ex.StackTrace } })); } }
public static string CoaleseField(this IPublishedContent currentNode, string property, string language = "") { if (currentNode == null) { return(""); } if (currentNode.HasProperty(property + language)) { property = property + language; } var content = currentNode.GetPropertyValue <string>(property); //make image full path return(PauHelper.MakeContentImageFullPath(content)); }
public static string GetMediaUrl(this IPublishedContent content, string property, string language) { if (!content.HasProperty(property)) { return(""); } if (content.HasProperty(property + language)) { property = property + language; } var media = AppContext.Current.MediaService.GetById(content.GetPropertyValue <int>(property)); if (media == null) { return(""); } var mediaUrl = media.GetValue(WellknownProperties.UmbracoFile).ToString(); //make image full path return(PauHelper.MakeImageFullPath(mediaUrl)); }
public HttpResponseMessage UpdateUserAddress(AddressModel model) { try { if (ModelState.IsValid) { var userInfo = _eloquaService.GetContactDetailsByEmail(model.EmailAddress); if (userInfo == null) { ModelState.AddModelError("EmailAddress", WellknownResponseMessages.EmailNotExisted); return(Request.CreateResponse(HttpStatusCode.BadRequest, new ResponseDTO { Success = false, StatusCode = 400, Message = WellknownResponseMessages.Falied, Errors = ModelState.AllErrors() })); } if (!ValidateIdentity(userInfo.EloquaContactId)) { ModelState.AddModelError("InvalidRequest", WellknownResponseMessages.InvalidRequest); return(Request.CreateResponse(HttpStatusCode.BadRequest, new ResponseDTO { Success = false, StatusCode = 400, Message = WellknownResponseMessages.Falied, Errors = ModelState.AllErrors() })); } var contactDetails = PauHelper.MapAddressModelToContactDetails(userInfo, model); var success = _eloquaService.UpdateContactDetails(contactDetails); if (success) { var emailHelper = new EmailHelper(); emailHelper.SendUpdateProfile(contactDetails.id); return(Request.CreateResponse(HttpStatusCode.OK, new ResponseDTO { Success = true, StatusCode = 200, Message = WellknownResponseMessages.Success })); } return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ResponseDTO { Success = false, StatusCode = 500, Message = WellknownResponseMessages.Falied, Errors = new List <string> { WellknownResponseMessages.ServerError } })); } return(Request.CreateResponse(HttpStatusCode.BadRequest, new ResponseDTO { Success = false, StatusCode = 400, Message = WellknownResponseMessages.Falied, Errors = ModelState.AllErrors() })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ResponseDTO { Success = false, StatusCode = 500, Message = WellknownResponseMessages.Falied, Errors = new List <string> { ex.Message + "\r\n" + ex.StackTrace } })); } }
public HttpResponseMessage RegisterProduct(PromotionRegisteredProductModel model) { try { if (ModelState.ContainsKey("model.PurchaseDate") && ModelState["model.PurchaseDate"].Errors.Any(x => x.Exception != null)) { ModelState.AddModelError("PurchaseDate", WellknownResponseMessages.InvalidPurchaseDateFormat); } if (ModelState.IsValid) { var userInfo = _eloquaService.GetContactDetailsByEmail(model.EmailAddress); if (userInfo == null) { ModelState.AddModelError("EmailAddress", WellknownResponseMessages.EmailNotExisted); return(Request.CreateResponse(HttpStatusCode.BadRequest, new ResponseDTO { Success = false, StatusCode = 400, Message = WellknownResponseMessages.Falied, Errors = ModelState.AllErrors() })); } if (!ValidateIdentity(userInfo.EloquaContactId)) { ModelState.AddModelError("InvalidRequest", WellknownResponseMessages.InvalidRequest); return(Request.CreateResponse(HttpStatusCode.BadRequest, new ResponseDTO { Success = false, StatusCode = 400, Message = WellknownResponseMessages.Falied, Errors = ModelState.AllErrors() })); } // If exsited Registed Product, do nothing and return failed var isRegisteredProduct = _eloquaService.IsRegistedProduct(model.ProductCategory, model.ProductSubCategory, model.ProductModelNumber, userInfo.EloquaContactId); if (isRegisteredProduct) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new ResponseDTO { Success = false, StatusCode = 400, Message = WellknownResponseMessages.Falied, Errors = new List <string> { WellknownResponseMessages.RegisteredProductExisted } })); } var registedProduct = PauHelper.MapPromotionRegistedProductModelToRegistedProductPost(model, userInfo.EloquaContactId); var success = _eloquaService.CreateRegisteredProduct(registedProduct); if (success) { return(Request.CreateResponse(HttpStatusCode.OK, new ResponseDTO { Success = true, StatusCode = 200, Message = WellknownResponseMessages.Success })); } return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ResponseDTO { Success = false, StatusCode = 500, Message = WellknownResponseMessages.Falied, Errors = new List <string> { WellknownResponseMessages.ServerError } })); } return(Request.CreateResponse(HttpStatusCode.BadRequest, new ResponseDTO { Success = false, StatusCode = 400, Message = WellknownResponseMessages.Falied, Errors = ModelState.AllErrors() })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ResponseDTO { Success = false, StatusCode = 500, Message = WellknownResponseMessages.Falied, Errors = new List <string> { ex.Message + "\r\n" + ex.StackTrace } })); } }