public async Task <CommitBlobResponse> Post([FromBody] CommitBlobRequest commitBlobRequest) { var res = new CommitBlobResponse(); var cs = new ContosoStorage(); string fileExt = BlobInformation.DEFAULT_FILE_EXT; fileExt = cs.CommitUpload(commitBlobRequest); var url = commitBlobRequest.SasUrl.Replace(AppSettings.StorageWebUri, ""); var urldata = url.Split('?'); var index = urldata[0].IndexOf('/'); var content = urldata[0].Split('/'); var containerName = urldata[0].Substring(0, index); string fileGuidName = urldata[0].Replace(containerName + "/lg/", "").Replace(".temp", ""); var ibl = new ImageBusinessLogic(); var image = ibl.AddImageToDB(commitBlobRequest.AlbumId, commitBlobRequest.UserId, containerName, fileGuidName + "." + fileExt, commitBlobRequest.IsMobile); if (image != null) { res.Success = true; res.ImageId = image.Id; } var qm = new QueueManager(); var blobInfo = new BlobInformation(fileExt); blobInfo.BlobUri = cs.GetBlobUri(containerName, urldata[0].Replace(containerName, "")); blobInfo.ImageId = fileGuidName; await qm.PushToResizeQueue(blobInfo); return(res); }
// POST: api/Like public async Task <bool> Post([FromBody] Dictionary <string, string> image) { var logic = new ImageBusinessLogic(); var img = logic.GetImage(image["imageId"]); if (null != img) { var ctx = new MobileServiceContext(); var registrations = ctx.DeviceRegistrations.Where(x => x.UserId == img.UserId); //Send plat-specific message to all installation one by one string message = "Someone has liked your image"; foreach (var registration in registrations) { var tags = new string[1] { string.Format("$InstallationId:{{{0}}}", registration.InstallationId) }; switch (registration.Platform) { case NotificationPlatform.Wns: await Notifier.Instance.sendWindowsStoreNotification(message, tags); break; case NotificationPlatform.Apns: await Notifier.Instance.sendIOSNotification(message, tags); break; case NotificationPlatform.Mpns: await Notifier.Instance.sendWPNotification(message, tags); break; case NotificationPlatform.Gcm: await Notifier.Instance.sendGCMNotification(message, tags); break; case NotificationPlatform.Adm: //NOT SUPPORTED break; default: break; } } } return(true); }