public void AddAdvancedPackage(AdvancedPackage advancedPackage) { _context.AdvancedPackages.Add(advancedPackage); }
public void RemoveAdvancedPackage(AdvancedPackage advancedPackage) { _context.AdvancedPackages.Remove(advancedPackage); }
public ActionResult Create(GigFormViewModel gigFormViewModel, HttpPostedFileBase upload) { // CHECK IF MODEL IS VALID if (!ModelState.IsValid) { return(View(gigFormViewModel)); } var userId = User.Identity.GetUserId(); // CREATE NEW GIG //Create a Basic Selling Package var basicPackage = new BasicPackage(gigFormViewModel); unitOfWork.BasicPackageRepository.AddBasicPackage(basicPackage); //Create an Advanced Selling Package var advancedPackage = new AdvancedPackage(gigFormViewModel); unitOfWork.AdvancedPackageRepository.AddAdvancedPackage(advancedPackage); //Create a Premium Selling Package var premiumPackage = new PremiumPackage(gigFormViewModel); unitOfWork.PremiumPackageRepository.AddPremiumPackage(premiumPackage); //Get the user Id in order to bind everything together var infleuncer = unitOfWork.InfluencerRepository.GetInfluencerForUser(userId); if (infleuncer == null) { return(HttpNotFound()); } // Create a Gig var gig = new Gig(gigFormViewModel, userId, infleuncer.ID); //IF THERE IS NEW FILE UPLOADED if (upload != null && upload.ContentLength > 0) { //WE WILL CREATE A NEW FILE WITH THE TYPE OF AVATAR (THIS IS WHAT I NEED HERE) var background = FileUpload.GiveGigBackground(System.IO.Path.GetFileName(upload.FileName), upload.ContentType, null, FileType.Photo, gig.ID); //BLACK MAGIC using (var reader = new System.IO.BinaryReader(upload.InputStream)) { background.Content = reader.ReadBytes(upload.ContentLength); } // GIVE INFLUENCER THE LIST OF FILES WITH THE AVATAR FILE gig.FileUploads = new List <FileUpload> { background }; } unitOfWork.GigsRepository.AddGig(gig); unitOfWork.Complete(); // WHEN EVERYTHING IS DONE GO TO INDEX return(RedirectToAction("Index")); }