/// <summary> /// Service method to create new member /// </summary> /// <param name="clubMember">club member model</param> /// <returns>true or false</returns> public bool Create(ClubMember clubMember) { using (var context = new SocialClubDbContext()) { context.ClubMembers.Add(clubMember); return context.SaveChanges() > 0; } }
/// <summary> /// Method to delete a club member /// </summary> /// <param name="id">member id</param> /// <returns>true / false</returns> public bool Delete(int id) { using (var context = new SocialClubDbContext()) { var clubMember = context.ClubMembers.Find(id); context.ClubMembers.Remove(clubMember); return context.SaveChanges() > 0; } }
/// <summary> /// Service method to update club member /// </summary> /// <param name="clubMember">club member</param> /// <returns>true / false</returns> public bool Update(ClubMember clubMember) { using (var context = new SocialClubDbContext()) { context.ClubMembers.Attach(clubMember); context.Entry(clubMember).State = EntityState.Modified; return context.SaveChanges() > 0; } }