コード例 #1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,Nome,Email")] Cliente cliente)
        {
            if (id != cliente.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cliente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClienteExists(cliente.Id))
                    {
                        return(NotFound());
                    }
                    throw;
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
コード例 #2
0
        public async Task <RxJob> UpdateAsync(RxJob job)
        {
            _context.Update(job);
            await _context.SaveChangesAsync();

            return(job);
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,BlogId,Url")] Blog blog)
        {
            if (id != blog.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(blog);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BlogExists(blog.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(blog));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,Password,Address,UserType")] 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));
        }
コード例 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,De_Id,Em_Code,FirstName,LastName,BirthDate,Phone,IdentityCardNumber,Sex,Address,Image,Status")] Employee employee)
        {
            if (id != employee.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeExists(employee.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
コード例 #6
0
ファイル: OwnerController.cs プロジェクト: renzy101/PPTDemo
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,DOB")] Owner owner)
        {
            if (id != owner.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(owner);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OwnerExists(owner.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(owner));
        }
コード例 #7
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,UserName,Password")] SiteUser siteUser)
        {
            if (id != siteUser.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(siteUser);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SiteUserExists(siteUser.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(siteUser));
        }
コード例 #8
0
ファイル: AttendeesController.cs プロジェクト: sgwin/TVUG
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Location")] Attendee attendee)
        {
            if (id != attendee.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(attendee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AttendeeExists(attendee.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(attendee));
        }
コード例 #9
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,SiteUserId")] Course course)
        {
            if (id != course.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(course);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourseExists(course.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SiteUserId"] = new SelectList(_context.Siteusers, "ID", "Name", course.SiteUserId);
            return(View(course));
        }
コード例 #10
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,Status")] Department department)
        {
            if (id != department.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(department);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentExists(department.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
コード例 #11
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Valor,Gratuito,Descricao,Data")] Evento evento)
        {
            if (id != evento.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(evento);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EventoExists(evento.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(evento));
        }
コード例 #12
0
ファイル: PetController.cs プロジェクト: renzy101/PPTDemo
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Age")] Pet pet)
        {
            if (id != pet.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pet);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PetExists(pet.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pet));
        }
コード例 #13
0
        /// </inheritdoc>
        public async Task <ItemDto> UpdateItemAsync(int id, ItemRequest request)
        {
            var item = await _context.Items.FindAsync(id);

            if (item == null)
            {
                throw new NotFoundException($"Item with {nameof(id)}: {id} not found");
            }

            _mapper.Map(request, item);
            _context.Update(item);
            await _context.SaveChangesAsync();

            return(_mapper.Map <ItemDto>(item));
        }
コード例 #14
0
        public async Task <IActionResult> Edit(int id, BookClass obj)
        {
            if (id != obj.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                _Context.Update(obj);
                await _Context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(obj));
        }
コード例 #15
0
        /// <summary>
        /// Updates a contact
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public async Task EditContact(Contact c)
        {
            try
            {
                var contact = await _demoContext.Contacts.FirstOrDefaultAsync(v => v.ContactId == c.ContactId);

                contact.Email = c.Email;
                contact.Name  = c.Name;
                contact.Phone = c.Phone;

                _demoContext.Update(contact);
                await _demoContext.SaveChangesAsync();
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #16
0
 public void UpdateProduct(Product product)
 {
     _context.Update(product);
 }
コード例 #17
0
 public IActionResult Update(Employee employee)
 {
     _context.Update(employee);
     _context.SaveChanges();
     return(Ok(employee));
 }