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

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

            Events events_map = Mapper.Map <Events>(_events);

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

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

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Puthotel_room_type([FromRoute] int id, [FromBody] HotelRoomTypeDTO hotel_room_type)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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


            HotelRoomType hotel_room_type_map = Mapper.Map <HotelRoomType>(hotel_room_type);

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutCompany([FromRoute] int id, [FromBody] CompanyDTO _company)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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


            try
            {
                Company company_map = Mapper.Map <Company>(_company);
                _context.Entry(company_map).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                var message = ex.Message;
                if (!CompanyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> PutNewsletter([FromRoute] int id, [FromBody] Newsletter newsletter)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }