Ejemplo n.º 1
0
 /// <summary>
 ///     Check if a User exist in the system
 /// </summary>
 /// <param name="source"></param>
 /// <param name="userEmail"></param>
 /// <returns></returns>
 public static bool UserExist(this CalDavContext source, string userEmail)
 {
     return((
                from user in source.Users
                where user.Email == userEmail
                select user).Any());
 }
Ejemplo n.º 2
0
 /// <summary>
 /// </summary>
 /// <param name="source"></param>
 /// <param name="userEmail">The email of the calendarResource's user.</param>
 /// <param name="collectionName">The collection where is the resource</param>
 /// <param name="calResource">the name of the resource</param>
 /// <returns>return a calendar resource by the given name.</returns>
 public static CalendarResource GetCalendarResource(this CalDavContext source, string userEmail,
                                                    string collectionName, string calResource)
 {
     return(source.GetCollection(userEmail, collectionName)
            .Calendarresources
            .First(cr => cr.Href == calResource));
 }
Ejemplo n.º 3
0
 /// <summary>
 ///     return a User for a given name
 /// </summary>
 /// <param name="source"></param>
 /// <param name="userEmail"></param>
 /// <returns></returns>
 public static User GetUser(this CalDavContext source, string userEmail)
 {
     try
     {
         return(source.Users.First(u => u.Email == userEmail));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 ///     return a collection for a given user and collectionName
 /// </summary>
 /// <param name="source"></param>
 /// <param name="userEmail"></param>
 /// <param name="collectionName"></param>
 /// <returns></returns>
 public static CalendarCollection GetCollection(this CalDavContext source, string userEmail,
                                                string collectionName)
 {
     try
     {
         return(source.GetUser(userEmail).CalendarCollections.First(cl => cl.Name == collectionName));
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        ///     Check if a collection exist in the system.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="userEmail"></param>
        /// <param name="collectionName"></param>
        /// <returns></returns>
        public static bool CollectionExist(this CalDavContext source, string userEmail, string collectionName)
        {
            if (!UserExist(source, userEmail))
            {
                return(false);
            }

            return((
                       from collection in GetUser(source, userEmail).CalendarCollections
                       where collection.Name == collectionName
                       select collection
                       ).Any());
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Check if a CalendarResource Exist
        /// </summary>
        /// <param name="source"></param>
        /// <param name="userEmail"></param>
        /// <param name="collectionName"></param>
        /// <param name="calResource"></param>
        /// <returns></returns>
        public static bool CalendarResourceExist(this CalDavContext source, string userEmail, string collectionName,
                                                 string calResource)
        {
            if (!CollectionExist(source, userEmail, collectionName))
            {
                return(false);
            }

            return((
                       from resource in GetCollection(source, userEmail, collectionName).Calendarresources
                       where resource.Href == calResource
                       select resource
                       ).Any());
        }