public SyncMessagesMethodResultDto SyncMessages(SyncMessagesMethodParametersDto pars)
        {
            var result = new SyncMessagesMethodResultDto { Items = new List<MailItemDto>() };

            if (!TestSession(pars.SessionId))
            {
                result.Message = "Session is expired or invalid";
                return result;
            }

            if (pars.Items != null)
            {
                foreach (MailItemDto mailItem in pars.Items)
                {
                    try
                    {
                        SaveMail(pars.ClientId, mailItem);
                    }
                    catch (Exception ex)
                    {
                        mailItem.SyncStatus = SyncMessagesMethodResultStatus.Failed;
                        result.Message +=
                            ex is CheckSumException ?
                                Environment.NewLine + "Check sum doesn't match for " + mailItem.Id :
                                string.Format(
                                    "{0}Error saving of message({1}) {2}",
                                    Environment.NewLine,
                                    ex.Message,
                                    mailItem.Id);
                    }
                    mailItem.Data = null;
                    result.Items.Add(mailItem);
                }
            }

            System.Threading.Thread.Sleep(500);

            return result;
        }
 public SyncMessagesMethodResultDto SyncMessages(SyncMessagesMethodParametersDto pars)
 {
     return Helper.MailsController.SyncMessages(pars);
 }