public async Task <IActionResult> Edit(Guid id, [Bind("Id,Nume,Prenume,Email,Telefon,Adresa,CNP")] ClientViewModels clientViewModels)
        {
            var client = clientViewModels.ToViewModels();

            if (id != client.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(client);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientViewModelsExists(client.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(client.ToViewModels()));
        }
Exemple #2
0
        // GET: ClientCRUD/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }

            ViewBag.District = _districtRep.GetAll();
            var client = _clientRep.GetById((int)id);
            var cv     = new ClientViewModels()
            {
                City_ID     = client.Addres.City_ID ?? 0,
                District_ID = client.Addres.District_ID ?? 0,
                Flat        = client.Addres.Flat,
                Street      = client.Addres.Street,
                Email       = client.Email,
                Idnp        = client.Idnp,
                Name        = client.Name,
                Phone       = client.Phone,
                Surname     = client.Surname,
                Client_ID   = client.Client_ID,
                Addres_ID   = client.Addres_ID
            };

            return(View(cv));
        }
        public async Task <IActionResult> Create([Bind("Id,Nume,Prenume,Email,Telefon,Adresa,CNP")] ClientViewModels clientViewModels)
        {
            var client = clientViewModels.ToViewModels();

            if (ModelState.IsValid)
            {
                client.Id = Guid.NewGuid();
                _context.Add(client);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(client.ToViewModels()));
        }
        private void ShowAddClientDialog()
        {
            _dialogService.ShowDialog(nameof(ClientAddingDialog), new DialogParameters {
                { "ClientViewModel", new ClientViewModel(new Client(), _bankEntities) }
            },
                                      async r =>
            {
                if (r.Result == ButtonResult.OK)
                {
                    var addedClientVm = r.Parameters.GetValue <ClientViewModel>("AddedClientViewModel");

                    _bankEntities.Clients.Add(addedClientVm.Entity);
                    await _bankEntities.SaveChangesAsync(CancellationToken.None);

                    ClientViewModels.Add(addedClientVm);
                }
            });
        }
Exemple #5
0
        public ActionResult Edit(int id, ClientViewModels clientV, int?cityDropDown)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var address = _addressRep.GetById((int)clientV.Addres_ID);
                    address.District_ID = clientV.District_ID;
                    if (cityDropDown != null)
                    {
                        address.City_ID = cityDropDown;
                    }

                    address.Flat   = clientV.Flat;
                    address.Street = clientV.Street;

                    _addressRep.Update(address.Addres_ID, address);
                    _addressRep.Save();

                    var client = _clientRep.GetById(clientV.Client_ID);
                    client.Surname   = clientV.Surname;
                    client.Email     = clientV.Email;
                    client.Idnp      = clientV.Idnp;
                    client.Name      = clientV.Name;
                    client.Phone     = clientV.Phone;
                    client.Addres_ID = clientV.Addres_ID;

                    _clientRep.Update(clientV.Client_ID, client);
                    _clientRep.Save();


                    return(RedirectToAction("Index"));
                }

                return(RedirectToAction("Edit"));
            }
            catch (Exception)
            {
                return(View());
            }
        }
Exemple #6
0
        public ActionResult Create(ClientViewModels clientV, int?cityDropDown)
        {
            try
            {
                var address = new Addres()
                {
                    City_ID     = cityDropDown,
                    District_ID = clientV.District_ID,
                    Flat        = clientV.Flat,
                    Street      = clientV.Street
                };

                _addressRep.Create(address);
                _addressRep.Save();
                var addressId = address.Addres_ID;

                var client = new Client()
                {
                    Name      = clientV.Name,
                    Surname   = clientV.Surname,
                    Email     = clientV.Email,
                    Idnp      = clientV.Idnp,
                    Phone     = clientV.Phone,
                    Addres_ID = addressId,
                };

                _clientRep.Create(client);
                _clientRep.Save();

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                return(View(e));
            }
        }
Exemple #7
0
 private void OnClientConnected(ClientDto clientDto)
 {
     if (Clients.TryGetValue(clientDto.ClientId, out var clientViewModel))
     {
         UpdateClientViewModel(clientViewModel, clientDto);
     }
     else
     {
         clientViewModel = new DefaultClientViewModel(clientDto);
         if (Clients.TryAdd(clientDto.ClientId, clientViewModel))
         {
             _appDispatcher.Current.BeginInvoke(DispatcherPriority.Background, (Action)(() => ClientViewModels.Add(clientViewModel)));
         }
     }
 }