public CMSResult Update(ClientAdmin clientAdmin)
        {
            var result = new CMSResult();
            var batch  = _repository.Project <ClientAdmin, bool>(users => (from u in users where u.UserId == clientAdmin.UserId select u).Any());

            if (!batch)
            {
                result.Results.Add(new Result {
                    Message = "Client Admin not exists."
                });
            }
            else
            {
                var clientAdminContact = _repository.Project <ClientAdmin, bool>(clientAdmins => (from a in clientAdmins where a.ContactNo == clientAdmin.ContactNo && a.UserId != clientAdmin.UserId select a).Any());
                if (clientAdminContact)
                {
                    result.Results.Add(
                        new Result
                    {
                        IsSuccessful = false,
                        Message      = string.Format("Contact Number already exists!")
                    });
                }

                if (!clientAdminContact)
                {
                    var ClientAdminUser = _repository.Load <ApplicationUser>(x => x.Id == clientAdmin.UserId, x => x.ClientAdmin);

                    ClientAdminUser.ClientAdmin.ClientId  = clientAdmin.ClientId;
                    ClientAdminUser.ClientAdmin.Name      = clientAdmin.Name;
                    ClientAdminUser.ClientAdmin.ContactNo = clientAdmin.ContactNo;
                    ClientAdminUser.ClientAdmin.Active    = clientAdmin.Active;

                    _repository.Update(ClientAdminUser);
                    result.Results.Add(new Result {
                        IsSuccessful = true, Message = string.Format("Client Admin '{0}' successfully updated!", clientAdmin.Name)
                    });
                }
            }

            return(result);
        }
        public CMSResult Save(ClientAdmin clientAdmin)
        {
            CMSResult result   = new CMSResult();
            var       isExists = _repository.Project <Client, bool>(clients => (from b in clients where b.Name == clientAdmin.Name select b).Any());

            if (isExists)
            {
                result.Results.Add(new Result {
                    IsSuccessful = false, Message = string.Format("Client '{0}' already exists!", clientAdmin.Name)
                });
            }
            else
            {
                _repository.Add(clientAdmin);
                result.Results.Add(new Result {
                    IsSuccessful = true, Message = string.Format("Client '{0}' successfully added!", clientAdmin.Name)
                });
            }
            return(result);
        }