Пример #1
0
        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;
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
 public void Add(Activity activity)
 {
     activity.Roles.SetState(_raisinDb, EntityState.Modified);
     _raisinDb.Activities.Add(activity);
 }