Beispiel #1
0
        public async Task <bool> UpdateClientDiversity(ClientDiversityViewModel model)
        {
            try
            {
                _context.Update(model);
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
Beispiel #2
0
        public async Task <bool> CreateClientDiversity(ClientDiversityViewModel model)
        {
            try
            {
                model.Id = Guid.NewGuid();
                _context.Add(model);
                await _context.SaveChangesAsync();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public async Task <IActionResult> Create(ClientDiversityViewModel clientDiversityViewModel)
        {
            if (ModelState.IsValid)
            {
                bool created = await _clientServices.CreateClientDiversity(clientDiversityViewModel);

                if (created)
                {
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    return(View(clientDiversityViewModel));
                }
            }
            return(View(clientDiversityViewModel));
        }
        public async Task <IActionResult> Edit(Guid id, ClientDiversityViewModel clientDiversityViewModel)
        {
            if (!_clientServices.ClientDiversityViewModelExists(clientDiversityViewModel.Id))
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var updated = await _clientServices.UpdateClientDiversity(clientDiversityViewModel);

                if (updated)
                {
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    return(View(clientDiversityViewModel));
                }
            }
            return(View(clientDiversityViewModel));
        }