public async Task <IActionResult> Edit(int id, [Bind("Id,Name,MiddleName,Surame")] Customer customer)
        {
            if (id != customer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,DepositAmount,DepositDate,AccountId")] Deposit deposit)
        {
            if (id != deposit.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(deposit);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepositExists(deposit.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", new { id = deposit.AccountId }));
            }
            ViewData["AccountId"] = new SelectList(_context.Accounts, "Id", "Id", deposit.AccountId);
            return(View(deposit));
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nom,Prenom,Telephone")] ContactModel contactModel)
        {
            if (id != contactModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contactModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContactModelExists(contactModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(contactModel));
        }
예제 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Count,InstrumentCheque,CustomerCheque")] Cheque cheque)
        {
            if (id != cheque.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cheque);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ChequeExists(cheque.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cheque));
        }
예제 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("id,Name,Descripcion,Slung")] City city)
        {
            if (id != city.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(city);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CityExists(city.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(city));
        }
예제 #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Cost,Count,IdBrandInstrument,IdMaterialInstrument,IdCountryInstrument,IdInstrumentTypeInstrument,IdShopInstrument")] Instrument instrument)
        {
            if (id != instrument.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(instrument);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InstrumentExists(instrument.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(instrument));
        }
예제 #7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,EventDate,Description,Picture,People,Duration,CityId")] Event @event)
        {
            if (id != @event.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@event);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EventExists(@event.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CityId"] = new SelectList(_context.Cities, "Id", "Name", @event.CityId);
            return(View(@event));
        }
예제 #8
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Address")] Client client)
        {
            if (id != client.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(client);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientExists(client.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
예제 #9
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,BookName,IsActive,PaymentAmount,PaymentMethodId")] Book book)
        {
            if (id != book.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(book);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookExists(book.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PaymentMethodId"] = new SelectList(_context.PaymentMethods, "Id", "Id", book.PaymentMethodId);
            return(View(book));
        }
예제 #10
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,Firstname,Surname,Email")] User user)
        {
            if (id != user.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
예제 #11
0
        public async Task <IActionResult> Edit(int id, [Bind("ParkId,Name,Description,City,State,WebsiteLink,ParkMapLink")] Park park)
        {
            if (id != park.ParkId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(park);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ParkExists(park.ParkId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(park));
        }
예제 #12
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Address,City,PhoneNumber")] Shop shop)
        {
            if (id != shop.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(shop);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ShopExists(shop.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(shop));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,InstrumentTypeName")] InstrumentType instrumentType)
        {
            if (id != instrumentType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(instrumentType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InstrumentTypeExists(instrumentType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(instrumentType));
        }
예제 #14
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,MiddleName,Surame,IdShopStaff,IdJobStaff")] Staff staff)
        {
            if (id != staff.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(staff);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StaffExists(staff.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(staff));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,JobName")] Job job)
        {
            if (id != job.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(job);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!JobExists(job.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(job));
        }
        public async Task <ProfileDto> EditProfileByIdAsync(string ownerId, ProfileReq input)
        {
            try
            {
                var existingProfile = await _dbContext.ProfileModels.Include(x => x.Competences)
                                      .Include(x => x.ImageModel)
                                      .Include(x => x.ProjectProfileRoles).ThenInclude(x => x.ProjectModel).ThenInclude(x => x.TimePeriod)
                                      .Include(x => x.ProjectProfileRoles).ThenInclude(x => x.ProjectModel).ThenInclude(x => x.Techniques)
                                      .FirstOrDefaultAsync(x => x.OwnerID == ownerId);

                if (input.OfficeModelId != 0)
                {
                    _dbContext.Entry(existingProfile).Property("OfficeModelId").CurrentValue = input.OfficeModelId;
                }

                existingProfile.AboutMe     = input.AboutMe;
                existingProfile.FirstName   = input.FirstName;
                existingProfile.LastName    = input.LastName;
                existingProfile.Position    = input.Position;
                existingProfile.LinkedInUrl = input.LinkedInUrl;
                existingProfile.ResumeUrl   = input.ResumeUrl;
                existingProfile.Modified    = DateTime.UtcNow;
                foreach (var competence in input.Competences)
                {
                    var existingCompetence = existingProfile.Competences.FirstOrDefault(c => c.Id == competence.Id);
                    if (existingCompetence == null)
                    {
                        existingProfile.Competences.Add(competence);
                    }
                    else
                    {
                        _dbContext.Entry(existingCompetence).CurrentValues.SetValues(competence);
                    }
                }

                foreach (var competence in existingProfile.Competences)
                {
                    if (!input.Competences.Any(c => c.Id == competence.Id))
                    {
                        _dbContext.Remove(competence);
                    }
                }
                _dbContext.Update(existingProfile);
                await _dbContext.SaveChangesAsync();

                return(_mapper.Map <ProfileModel, ProfileDto>(existingProfile));
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
예제 #17
0
        public async Task <ImageDto> EditImageModelAsync(int imageId, ImageModel imageModel)
        {
            try
            {
                var existingImageModel = await GetImageModelByIdAsync(imageId);

                existingImageModel.Url      = imageModel.Url;
                existingImageModel.Alt      = imageModel.Alt;
                existingImageModel.Modified = DateTime.UtcNow;
                _dbContext.Update(existingImageModel);
                await _dbContext.SaveChangesAsync();

                return(_mapper.Map <ImageModel, ImageDto>(imageModel));
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }