public async Task<ValidationResult> ShareCalendar(ShareDetails model)
        {
            try
            {
                //Parse guid
                Guid? guid = ParseGuid(model.CalendarId);
                if (guid == null) return AddError("Unable to parse calendarId");

                //Check calendar exists
                var cal = await _calendarRepo.Get(x => x.Id == guid.Value)
                    .Include(x => x.Owner).FirstOrDefaultAsync();

                if (cal == null)
                    return AddError("Calendar was not found");

                //Check if the recipient is a member of the app
                var user = await _userRepo.Get(x => x.Email == model.Email).FirstOrDefaultAsync();

                //If this user isn't registered send invite email
                if (user == null)
                {
                    await SendInvitationEmail(model);
                    Result.Success = true;
                    return Result;
                }
                
                //Check for an existing calendar invitation
                Invitation existingInvitation = await _invitationService.CheckForDuplicates(user.Id, model.SenderUserId, guid.Value, null);

                if (existingInvitation != null)
                    return AddError("An invitation matching the specified values already exists");

                //Assuming we have a registered user and no existing invitation, create a new one
                Invitation inv = new Invitation
                {
                    CalendarId = guid.Value,
                    RecipientId = user.Id,
                    SenderId = model.SenderUserId,
                    TypeId = (int)LookUpEnums.InvitationTypes.Calendar,
                    DisplayMessage = $"{cal.Owner.Name} has invited you to share their calendar \"{cal.Name}\""
                };

                await _invitationService.AddInvitation(inv);
                
                //Finally send out GCM notification
                string message = $"{cal.Owner.Name} wants to share their Calendar";

                //Send the notification
                AndroidGCMPushNotification.SendNotification(user.DeviceId, message);

                Result.Success = true;
                return Result;
            }
            catch (Exception ex)
            {
                Result.Error = ex.Message;
                return Result;
            }
        }
 public async Task<bool> AddInvitation(Invitation inv)
 {
     try
     {
         _inviteRepo.Insert(inv);
         await SaveChangesAsync();
         return true;
     }
     catch (Exception ex)
     {
         return false;
     }
 }