public async Task <Event> UpdateAsync(Event model, int?id = null)
        {
            Events eventDataAccess = Mapper.Map <Event, Events>(model);

            if (id == null)
            {
                throw new ArgumentException("Nedded id", nameof(id));
            }

            Events tracked = _db.Events.Find(id);

            if (tracked == null)
            {
                throw new ArgumentException("No Event with this id", nameof(id));
            }

            _db.Entry(tracked).CurrentValues.SetValues(eventDataAccess);
            model = Mapper.Map <Events, Event>(eventDataAccess);

            return(model);
        }
        public async Task <Room> UpdateAsync(Room model, int?id = null)
        {
            Rooms room = Mapper.Map <Room, Rooms>(model);

            if (id == null)
            {
                throw new ArgumentException("Needed id", nameof(id));
            }

            Rooms tracked = _db.Rooms.Find(id);

            if (tracked == null)
            {
                throw new ArgumentException("No Room with this id", nameof(id));
            }

            _db.Entry(tracked).CurrentValues.SetValues(room);
            model = Mapper.Map <Rooms, Room>(room);

            return(model);
        }
示例#3
0
        public async Task <Customer> UpdateAsync(Customer model, int?id = null)
        {
            Customers customer = Mapper.Map <Customer, Customers>(model);

            if (id == null)
            {
                throw new ArgumentException("Nedded id", nameof(id));
            }

            Customers tracked = _db.Customers.Find(id);

            if (tracked == null)
            {
                throw new ArgumentException("No Customer with this id", nameof(id));
            }

            _db.Entry(tracked).CurrentValues.SetValues(customer);
            model = Mapper.Map <Customers, Customer>(customer);

            return(model);
        }
        public async Task <Employee> UpdateAsync(Employee model, int?id = null)
        {
            Employees employee = Mapper.Map <Employee, Employees>(model);

            if (id == null)
            {
                throw new ArgumentException("Nedded id", nameof(id));
            }

            Employees tracked = _db.Employees.Find(id);

            if (tracked == null)
            {
                throw new ArgumentException("No Employee with this id", nameof(id));
            }

            _db.Entry(tracked).CurrentValues.SetValues(employee);
            model = Mapper.Map <Employees, Employee>(employee);

            return(model);
        }
        public async Task <Reservation> UpdateAsync(Reservation model, int?id = null)
        {
            Reservations reservation = Mapper.Map <Reservation, Reservations>(model);

            if (id == null)
            {
                throw new ArgumentException("Nedded id", nameof(id));
            }

            Reservations tracked = _db.Reservation.Find(id);

            if (tracked == null)
            {
                throw new ArgumentException("No Reservation with this id", nameof(id));
            }

            _db.Entry(tracked).CurrentValues.SetValues(reservation);
            model = Mapper.Map <Reservations, Reservation>(reservation);

            return(model);
        }