public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description,ProcessId,ContactId,FromId,ProductId,UserId")] Deal deal)
        {
            if (id != deal.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(deal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DealExists(deal.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContactId"] = new SelectList(_context.Contacts, "Id", "FirstName", deal.ContactId);
            ViewData["FromId"]    = new SelectList(_context.Froms, "Id", "Name", deal.FromId);
            ViewData["ProcessId"] = new SelectList(_context.Processes, "Id", "Title", deal.ProcessId);
            ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Description", deal.ProductId);
            ViewData["UserId"]    = new SelectList(_context.Users, "Id", "FirstName", deal.UserId);
            return(View(deal));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Order")] Process process)
        {
            if (id != process.Id)
            {
                return(NotFound());
            }


            if (ModelState.IsValid)
            {
                try
                {
                    if (_context.Processes.AsNoTracking().Any(m => m.Order == process.Order))
                    {
                        var processWithExistingOrder = await _context.Processes.AsNoTracking().SingleOrDefaultAsync(m => m.Order == process.Order);

                        if (processWithExistingOrder != null)
                        {
                            if (processWithExistingOrder.Id != process.Id)
                            {
                                var processLegacy = await _context.Processes.AsNoTracking().SingleOrDefaultAsync(m => m.Id == id);

                                if (processLegacy != null)
                                {
                                    processWithExistingOrder.Order = processLegacy.Order;
                                    _context.Update(processWithExistingOrder);
                                }
                            }
                        }
                    }

                    _context.Update(process);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProcessExists(process.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Deals"));
            }
            return(View(process));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("ItemId,ItemName,Price,ItemDescription,ImageData,Category")] Item item)
        {
            if (id != item.ItemId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(item);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemExists(item.ItemId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Category"] = new SelectList(_context.Category, "CategoryId", "Name", item.Category);
            return(View(item));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Address,City,State,DateOfBirth,Gender")] Student student)
        {
            if (id != student.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Home"));
            }
            return(View(student));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, [Bind("OrderId,DailyDeal,Quantity,Price,OrderType,CurrentStatus,OrderMessage,Table,Message")] DailyDealOrder dailyDealOrder)
        {
            if (id != dailyDealOrder.OrderId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dailyDealOrder);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DailyDealOrderExists(dailyDealOrder.OrderId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DailyDeal"] = new SelectList(_context.DailyDeal, "DailyDealId", "DailyDealId", dailyDealOrder.DailyDeal);
            ViewData["OrderType"] = new SelectList(_context.OrderType, "TypeId", "OrderType1", dailyDealOrder.OrderType);
            return(View(dailyDealOrder));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,CourseId")] Test test)
        {
            if (id != test.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(test);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TestExists(test.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"] = new SelectList(_context.Courses, "Id", "Name", test.CourseId);
            return(View(test));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,UserId")] 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["UserId"] = new SelectList(_context.Users, "Id", "FirstName", course.UserId);
            return(View(course));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Edit(int id, [Bind("EventId,EventName,EventStartDate,EventLocation,EventInformation,HasEventPassed,NumberOfTotalParticipants")] Event @event)
        {
            if (id != @event.EventId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@event);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EventExists(@event.EventId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(@event));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Edit(int id, [Bind("ReservationId,DateAndTime,LastName,PeopleNo")] Reservation reservation)
        {
            if (id != reservation.ReservationId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reservation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReservationExists(reservation.ReservationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reservation));
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Edit(int id, [Bind("ParticipantId,EventId,Type,PersonId,CompanyId")] Participant participant)
        {
            if (id != participant.ParticipantId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(participant);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ParticipantExists(participant.ParticipantId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"] = new SelectList(_context.Events, "EventId", "EventId", participant.EventId);
            return(View(participant));
        }
        public async Task<IActionResult> Edit(int id, [Bind("ID,Title,ReleaseDate,Genre,Price")] Movie movie)
        {
            if (id != movie.ID)
            {
                return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(movie);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieExists(movie.ID))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                return RedirectToAction(nameof(Index));
            }
            return View(movie);
        }
Exemplo n.º 12
0
        public async Task <IActionResult> Edit(int id, [Bind("CategoriaID,Nombre,Descripcion,Estado")] Categoria categoria)
        {
            if (id != categoria.CategoriaID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categoria);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoriaExists(categoria.CategoriaID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoria));
        }
Exemplo n.º 13
0
        public async Task <IActionResult> Edit(int id, [Bind("CompanyId,CompanyName,CompanyRegistrationNr,CompanyPaymentMehtod,NumberOfParticipants,CompanyRequests,ParticipantId")] Company company)
        {
            if (id != company.CompanyId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(company);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompanyExists(company.CompanyId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(company));
        }
Exemplo n.º 14
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Brand,Model,Year,Hk,Price")] Car car)
        {
            if (id != car.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(car);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarExists(car.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(car));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Description,TestId")] Question question)
        {
            if (id != question.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(question);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!QuestionExists(question.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", "Tests", new { id = question.TestId }));
            }
            ViewData["TestId"] = new SelectList(_context.Tests, "Id", "Name", question.TestId);
            return(View(question));
        }
Exemplo n.º 16
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Role role)
        {
            if (id != role.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(role);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RoleExists(role.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(role));
        }
Exemplo n.º 17
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Phone,Address")] Company company)
        {
            if (id != company.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(company);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompanyExists(company.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(company));
        }
Exemplo n.º 18
0
        public async Task <IActionResult> Edit(bool id, [Bind("TypeId,OrderType1")] OrderType orderType)
        {
            if (id != orderType.TypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orderType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderTypeExists(orderType.TypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(orderType));
        }
Exemplo n.º 19
0
        public async Task <IActionResult> Edit(int id, [Bind("PersonId,FirstName,LastName,PersonalCode,PersonPaymentMethod,PersonRequests,ParticipantId")] Person person)
        {
            if (id != person.PersonId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(person);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PersonExists(person.PersonId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(person));
        }
Exemplo n.º 20
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,Patronymic,LastName,About,Photo,Login,Password,RoleId,GroupId")] 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)));
            }
            ViewData["GroupId"] = new SelectList(_context.Groups, "Id", "Name", user.GroupId);
            ViewData["RoleId"]  = new SelectList(_context.Roles, "Id", "Name", user.RoleId);
            return(View(user));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,SectionId")] SubSection subSection)
        {
            if (id != subSection.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(subSection);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubSectionExists(subSection.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["SectionId"] = new SelectList(_context.Sections, "Id", "Name", subSection.SectionId);
            return(View(subSection));
        }
Exemplo n.º 22
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Date,Latitude,Longitude,GeoPolygon,Photo,PhotoName,FileType,Geolocalization,GeoJSON,FireTypeClassification,SmokeTypeClassification,FireScoreClassification,SmokeScoreClassification")] ClassifiedImage classifiedImage)
        {
            if (id != classifiedImage.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(classifiedImage);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClassifiedImageExists(classifiedImage.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(classifiedImage));
        }
Exemplo n.º 23
0
        public async Task <IActionResult> Edit(int id, [Bind("DailyDealId,DailyDealName,DailyDealImage,DailyDealDescription,DailyDealPrice,DailyDealQuantity,DailyDealDate")] DailyDeal dailyDeal)
        {
            if (id != dailyDeal.DailyDealId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dailyDeal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DailyDealExists(dailyDeal.DailyDealId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(dailyDeal));
        }
Exemplo n.º 24
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Names,BirthDate,Gender,Worth")] People people)
        {
            if (id != people.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(people);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PeopleExists(people.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(people));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,Phone,Message,ProductId")] Feedback feedback)
        {
            if (id != feedback.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(feedback);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FeedbackExists(feedback.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", feedback.ProductId);
            return(View(feedback));
        }
Exemplo n.º 26
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Color")] Product product)
        {
            if (id != product.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Exemplo n.º 27
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FullName,Department, Email, Telephone")] 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));
        }
Exemplo n.º 28
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Code,Name,Description")] Course course)
        {
            if (id != course.Id)
            {
                return(NotFound());
            }

            if (IsCourseCodeExist(course) == true)
            {
                ModelState.AddModelError("Code", "CourseCode already exists");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(course);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourseExists(course.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Home"));
            }
            return(View(course));
        }
Exemplo n.º 29
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,Patronymic,LastName,Phone,Address,CompanyId")] Contact contact)
        {
            if (id != contact.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contact);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContactExists(contact.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Name", contact.CompanyId);
            return(View(contact));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,RefreshTime")] Site site)
        {
            if (id != site.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(site);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SiteExists(site.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(site));
        }