public static Activity Add(Activity activity) { using (var db = ObjectProvider.CreateDB()) { activity.Roles.SetState(db, EntityState.Modified); db.Activities.Add(activity); db.SaveChanges(); return activity; } }
private static void AddActivity(RaisinsDB context, string activityName, params string[] roleNames) { if (!context.Activities.Any(a => a.Name == activityName)) { Activity newActivity = new Activity() { Name = activityName }; List<Role> roles = new List<Role>(); foreach (string roleName in roleNames) { roles.Add(Role.Find(roleName)); } newActivity.Roles = roles; Activity.Add(newActivity); } }
private void AddActivity(string activityName, params string[] roleNames) { if (!_unitOfWork.Activities.Any(activityName)) { Activity newActivity = new Activity() { Name = activityName }; List<Role> roles = new List<Role>(); foreach (string roleName in roleNames) { roles.Add(_unitOfWork.Roles.Get(roleName)); } newActivity.Roles = roles; _unitOfWork.Activities.Add(newActivity); } }
public void Add(Activity activity) { activity.Roles.SetState(_raisinDb, EntityState.Modified); _raisinDb.Activities.Add(activity); }