コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("RentedLocationId,PlaceName,Address,OnDate,VacatedDate,City,OwnerName,MobileNo,RentAmount,AdvanceAmount,IsRented,RentType,StoreId,UserId,IsReadOnly")] RentedLocation rentedLocation)
        {
            if (id != rentedLocation.RentedLocationId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(rentedLocation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RentedLocationExists(rentedLocation.RentedLocationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StoreId"] = new SelectList(_context.Stores, "StoreId", "StoreName", rentedLocation.StoreId);
            return(PartialView(rentedLocation));
        }
コード例 #2
0
        public async Task <ActionResult <RentedLocation> > PostRentedLocation(RentedLocation rentedLocation)
        {
            _context.RentedLocations.Add(rentedLocation);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetRentedLocation", new { id = rentedLocation.RentedLocationId }, rentedLocation));
        }
コード例 #3
0
        public async Task <IActionResult> PutRentedLocation(int id, RentedLocation rentedLocation)
        {
            if (id != rentedLocation.RentedLocationId)
            {
                return(BadRequest());
            }

            _context.Entry(rentedLocation).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RentedLocationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("RentedLocationId,PlaceName,Address,OnDate,VacatedDate,City,OwnerName,MobileNo,RentAmount,AdvanceAmount,IsRented,RentType,StoreId,UserId,IsReadOnly")] RentedLocation rentedLocation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rentedLocation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StoreId"] = new SelectList(_context.Stores, "StoreId", "StoreName", rentedLocation.StoreId);
            return(PartialView(rentedLocation));
        }