public void Create(ServiceView serviceView) { if (serviceView == null) throw new ArgumentNullException("serviceView"); var service = serviceView.Convert(); _dbContext.Services.Add(service); _dbContext.SaveChanges(); }
public void Create(ServiceView serviceView, IEnumerable<string> permissions) { if (serviceView == null) throw new ArgumentNullException("serviceView"); if (permissions == null) throw new ArgumentNullException("permissions"); var service = serviceView.Convert(); foreach (var permission in permissions) service.Permissions.Add(new ServicePermission() { Name = permission, Service = service }); _dbContext.Services.Add(service); _dbContext.SaveChanges(); }