public IHttpActionResult SetPictureAs(EntitySetImageModel model) { var uploadType = model.UploadType; var pictureId = model.PictureId; /*Due to caching, generic attributes don't update the data somehow from apicontrollers*/ //TODO: Find a workaround to this issue //for now we have created an extension method to bypass cache for retrieve. eventually this works for now string key = ""; switch (uploadType) { case "cover": key = AdditionalCustomerAttributeNames.CoverImageId; break; case "avatar": key = SystemCustomerAttributeNames.AvatarPictureId; break; } //get the attribute with our extension method var attribute = _genericAttributeService.GetAttributeByKey(_workContext.CurrentCustomer, key); if (attribute == null) { _genericAttributeService.SaveAttribute(_workContext.CurrentCustomer, key, pictureId); } else { attribute.Value = pictureId.ToString(); _genericAttributeService.UpdateAttribute(attribute); } return(Json(new { Success = true })); }