コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CompanyName,ContactPerson,LicenseNo,Mobile,ContactNo,Email,Country,City")] BrokerRequirement brokerRequirement)
        {
            if (id != brokerRequirement.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(brokerRequirement);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BrokerRequirementExists(brokerRequirement.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(brokerRequirement));
        }
コード例 #2
0
        public async Task <IActionResult> Create(BrokerRequirementCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                BrokerRequirement brokerRequirement = new BrokerRequirement
                {
                    ContactPerson = model.ContactPerson,
                    LicenseNo     = model.LicenseNo,
                    Mobile        = model.Mobile,
                    ContactNo     = model.ContactNo,
                    Email         = model.Email,
                    Country       = model.Country,
                    City          = model.City,
                };
                _context.Add(brokerRequirement);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }