//CRUD // create read update delete public Fund CreateFund(FundOption fndOption) { Fund fund = new Fund { Amount = fndOption.Amount, FundDate = fndOption.FundDate, }; db.Funds.Add(fund); db.SaveChanges(); return(fund); }
//CRUD // create read update delete public User CreateUser(UserOption usrOption) { User user = new User { FirstName = usrOption.FirstName, LastName = usrOption.LastName, Email = usrOption.Email }; db.Users.Add(user); db.SaveChanges(); return(user); }
//CRUD // create read update delete public Media CreateMedia(MediaOption medOption) { Media media = new Media { MediaPath = medOption.MediaPath, Type = medOption.Type, Date = medOption.Date, }; db.Medias.Add(media); db.SaveChanges(); return media; }
//CRUD // create read update delete public BackedFunds CreateBackedFunds(BackedFundsOption bfnOption) { BackedFunds BackedFunds = new BackedFunds { BackedFundsId = bfnOption.BackedFundsId, //UserId = bfnOption.UserId, // User = bfnOption.User, FundId = bfnOption.FundId, //Fund = bfnOption.Fund, //DateBacked = bfnOption.DateBacked }; db.BackedFunds.Add(BackedFunds); db.SaveChanges(); return(BackedFunds); }
//CRUD // create read update delete public Project CreateProject([FromForm] CreateProjectOption createProjectOption) { User user = db.Set <User>().Find(createProjectOption.ProjectCreatorId); Project project = new Project { ProjectName = createProjectOption.ProjectName, ProjectCreator = user, Description = createProjectOption.Description, Goal = createProjectOption.Goal, End = createProjectOption.End, Progress = createProjectOption.Progress, IsActive = true, ProjectCategory = createProjectOption.ProjectCategory, ImagePath = createProjectOption.ImagePath, Funds = new List <Fund> { new Fund { Amount = createProjectOption.Amount, Reward = createProjectOption.Reward } }, //Fund fund = new Fund { // Amount = FundOption.Amound }; db.Projects.Add(project); db.SaveChanges(); return(project); }