public bool CreateClient(Client client)
 {
     try
     {
         _repository.CreateClient(client);
         return true;
     }
     catch (Exception ex)
     {
         _validationDictionary.AddError("_FORM", "Client is not saved. " + ex.Message);
         return false;
     }
 }
        private ClientViewModel FillViewData(Client client)
        {
            ClientViewModel viewModel;

            var userHelper = new DropDownHelper();

            if (client == null)
            {
                viewModel = new ClientViewModel
                                {
                                    Roles = userHelper.GetRoles(ROLES.client.ToString()),
                                    Profiles = _profileService.SelectListProfiles(null),
                                    Statuses = _statusService.ListStatuses(null)
                                };
            }
            else
            {
                viewModel = _facade.ClientService.GetViewModel(client);
                viewModel.Roles = userHelper.GetRoles(client.Role);
                viewModel.Profiles = _profileService.SelectListProfiles(client.ProfileId);
                //viewModel.Statuses = _statusService.ListStatuses(client.Status.StatusId);// 2---------------
                viewModel.Statuses = _statusService.ListStatuses(client.Status.StatusId);
                viewModel.StatusId = client.Status.StatusId;
            }
            return viewModel;
        }
 public ClientViewModel GetViewModel(Client client)
 {
     Mapper.CreateMap<Client, ClientViewModel>();
     return Mapper.Map<Client, ClientViewModel>(client);
 }
Ejemplo n.º 4
0
 public List<Client> ListContacts()
 {
     var clients = new List<Client>();
     foreach (var user in UserService.ListUsers())
     {
         user.astra_ClientsReference.Load();
         Client client;
         if (user.astra_ClientsReference.Value == null)
             client = new Client
                          {
                              UserName = user.UserName
                          };
         client = user.astra_ClientsReference.Value;
         client.Role = UserService.GetRoleForUser(user.UserName);
         client.UserName = user.UserName;
         client.LoadReferences();
         clients.Add(client);
     }
     return clients;
 }