public ResponseBase ConfirmEditedMusic(Music music, Model.File WAVUpload, Model.File MP3Upload, ConfirmTypeAction confirmAction, string DeclineReason) { ResponseBase res = new ResponseBase(); try { // delete from confirmation table Confirmation conf = ((ConfirmationRepository)this._rep) .GetByEntityId(music.ID.ToString()); if (conf != null) { this._rep.Delete(conf); switch (confirmAction) { case ConfirmTypeAction.Ok: // update source music by music music.Status = MusicActiveStatus.Public; if (_MusicSrv.Update(music, music.SourceMusicId.Value, WAVUpload, MP3Upload).Success) { // Delete temp music _MusicSrv.DeleteBy(music.ID); } break; case ConfirmTypeAction.Decline: _MusicSrv.Update(music, music.ID, WAVUpload, MP3Upload); _emailService.DeclineNewUpdateMusic(music.Artist.User.Email, DeclineReason, music.HebrewName); break; case ConfirmTypeAction.Block: // Delete from temp _MusicSrv.DeleteBy(music.ID); // Set the source music as blocked var SourceMusic = _MusicRep.GetByID(music.SourceMusicId.Value); SourceMusic.Status = MusicActiveStatus.Blocked; _MusicRep.Update(SourceMusic); break; } this._uow.Commit(); res.Success = true; } else { res.Message = "לא הצלחנו לאתר נתונים"; res.Success = false; } } catch (Exception e) { res.Message = e.Message; res.Success = false; } return(res); }
public ResponseBase SaveNewPurchase(int?MusicId, PaskolUser Buyer, double Total, Guid permId) { ResponseBase res = new ResponseBase(); try { Music music = null; if (MusicId != null && Buyer != null) { music = _musicRep.GetByID(MusicId.Value); if (music != null) { var file = new Model.File() { FileType = FileType.PDF, suffix = ".pdf", UserId = Buyer.Id, }; Purchase newPurchase = new Purchase(); newPurchase.Customer = Buyer; newPurchase.Music = music; newPurchase.PurchaseCost = Total; newPurchase.PurchaseStatus = PurchaseStatus.NotPaidToArtist; newPurchase.PurchaseDate = DateTime.Now; newPurchase.Permision = _permissionRep.GetByID(permId); newPurchase.CustomerReference = "";//TODO newPurchase.PurchaseAgreement = file; this._rep.Add(newPurchase); this._uow.Commit(); string pathToDownload = string.Format(CommonHelper.GetBaseUrl() + "/File/GetFile?FileId={0}&UserId={1}&FileType={2}&version={3}&suffix={4}&FileName={5}" , music.WAVFileID, music.ArtistID, FileType.Music, music.WAVFile.version, music.WAVFile.suffix, music.HebrewName); string permissions = string.Join(", ", newPurchase.Permision.PropertyValues .Where(pv => !pv.PermissionProperty.IsCostLevel) .Select(pv => pv.PermissionProperty.Name + " - " + pv.Name)); // Create Report _pdfService.PurchaseAgreement( WebConf.FSBaseRoute, Path.GetFileName(file.RelativePath), Buyer.Id, DateTime.Now, Buyer.UserName, Buyer.Email, music.HebrewName, music.MusicWriter, music.MusicComposer, music.MusicPerformer, permissions, newPurchase.PurchaseCost.HasValue ? newPurchase.PurchaseCost.Value : 0, newPurchase.CustomerReference, newPurchase.Music.Exceptions); // notify artist and customer this._emailSrv.AlertArtistPurchaseSuccess(newPurchase.Music.Artist.User.Email); this._emailSrv.AlertBuyerPurchaseSuccess(newPurchase.Customer.Email, pathToDownload); res.Success = true; } } if (music == null || Buyer == null) { res.Success = false; res.Message = "לא הצלחנו לזהות לקוח או מוזיקה"; } } catch (Exception e) { res.Message = e.Message; res.Success = false; } return(res); }