Ejemplo n.º 1
0
        public async Task <IActionResult> PutUser([FromRoute] int id, [FromBody] User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != user.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("IdAddress,Country,City,Number")] Address address)
        {
            if (ModelState.IsValid)
            {
                _context.Add(address);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(address));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("IdRent,CheckIn,CheckOut")] Rent rent)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rent);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(rent));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("IdRating,HostRate,Communication,Location,Value,Accuracy,Cleanliness")] Rating rating)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rating);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(rating));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("IdSpecs,Created,Updated,Description,Amenities")] Spec spec)
        {
            if (ModelState.IsValid)
            {
                _context.Add(spec);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(spec));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("IdRole,Name,Activity")] Role role)
        {
            if (ModelState.IsValid)
            {
                _context.Add(role);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(role));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("IdDevice,DeviceName,Description")] Device device)
        {
            if (ModelState.IsValid)
            {
                _context.Add(device);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(device));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("IdPlace,AddressId,Description,Price,Availability,Rooms,MaxOfGuests")] Place place)
        {
            if (ModelState.IsValid)
            {
                _context.Add(place);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AddressId"] = new SelectList(_context.Addresses, "IdAddress", "IdAddress", place.AddressId);
            return(View(place));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Username,Password,Email,Created,LastUpdate,LastLog,IdDevice")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdDevice"] = new SelectList(_context.Devices, "IdDevice", "DeviceName", user.IdDevice);
            return(View(user));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("IdURole,IdUser,IdRole")] UserRole userRole)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userRole);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdRole"] = new SelectList(_context.Roles, "IdRole", "Name", userRole.IdRole);
            return(View(userRole));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Create([Bind("IdReview,OfferId,UserRoleId,Date,RatingId,Comment")] Review review)
        {
            if (ModelState.IsValid)
            {
                _context.Add(review);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OfferId"]  = new SelectList(_context.Offers, "IdOffer", "IdOffer", review.OfferId);
            ViewData["RatingId"] = new SelectList(_context.Ratings, "IdRating", "IdRating", review.RatingId);
            return(View(review));
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> Create([Bind("IdOffer,PlaceId,RentId,UserRoleId,Date")] Offer offer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(offer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PlaceId"]    = new SelectList(_context.Places, "IdPlace", "IdPlace", offer.PlaceId);
            ViewData["RentId"]     = new SelectList(_context.Rents, "IdRent", "IdRent", offer.RentId);
            ViewData["UserRoleId"] = new SelectList(_context.UserRoles, "IdURole", "IdURole", offer.UserRoleId);
            return(View(offer));
        }