public bool RemoveClientFromService(ClientInServices clientInServices)
 {
     var _service = _entities.ClientInServicesSet.Where(a => a.ActivityId == clientInServices.ActivityId).FirstOrDefault();
     _entities.DeleteObject(_service);
     _entities.SaveChanges();
     return true;
 }
 public ClientInServices UpdateActivity(ClientInServices activity)
 {
     var _activity = _entities.ClientInServicesSet.Where(a => a.ActivityId == activity.ActivityId).FirstOrDefault();
     _entities.ApplyPropertyChanges(_activity.EntityKey.EntitySetName, activity);
     //_activity.EndDate = DateTime.Now;
     _entities.SaveChanges();
     return _activity;
 }
 public ClientInServices CreateActivity(ClientInServices activity)
 {
     activity.astra_Clients = _entities.Clients.Where(c => c.UserId == activity.ClientId).FirstOrDefault();
     activity.astra_Services = _entities.ServiceSet.Where(s => s.ServiceId == activity.ServiceId).FirstOrDefault();
     activity.aspnet_Users = _entities.Users.Where(u => u.UserId == activity.UserId).FirstOrDefault();
     activity.Date = DateTime.Now;
     _entities.AddToClientInServicesSet(activity);
     _entities.SaveChanges();
     return activity;
 }
 public bool CreateActivity(ClientInServices activity)
 {
     try
     {
         _repository.CreateActivity(activity);
         return true;
     }
     catch (Exception ex)
     {
         _validationDictionary.AddError("_FORM", "Client is not saved. " + ex.Message);
         return false;
     }
 }
        public bool AddClientToService(Guid clientId, int serviceId)
        {
            var activity = new ClientInServices
                               {
                                   ClientId = clientId,
                                   ServiceId = serviceId,
                                   UserId = _userHelper.GetCurrentUserId
                               };

            if (CreateActivity(activity))
                return true;
            return false;
        }