Ejemplo n.º 1
0
        public async Task <IActionResult> PostTableBook([FromBody] TableBook tableBook)

        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.TableBook.Add(tableBook);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (TableBookExists(tableBook.Idbook))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }
            return(CreatedAtAction("GetTableBook", new { id = tableBook.Idbook }, tableBook));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutTableBook([FromRoute] int id, [FromBody] TableBook tableBook)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tableBook.Idbook)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 3
0
        public async Task <TableBookVM> CreateTableBookAsync(CreateTableBookVM table)
        {
            var dbTable = new TableBook
            {
                EndTime   = table.EndTime,
                StartTime = table.StartTime,
                BookTime  = table.BookTime,
                IsConfirm = null,
                IsActive  = table.IsActive,
                TableId   = table.TableId,
                Comment   = table.Comment,
                ClientId  = table.ClientId
            };
            var tableNew = await _db.TableBooks.CreateAsync(dbTable);

            var ret = new TableBookVM(tableNew);

            return(ret);
        }
Ejemplo n.º 4
0
 public TableBookVM(TableBook t)
 {
     Id        = t.Id;
     StartTime = t.StartTime;
     EndTime   = t.EndTime;
     BookTime  = t.BookTime;
     IsActive  = t.IsActive;
     Comment   = t.Comment;
     IsConfirm = t.IsConfirm;
     if (t.Table != null)
     {
         TableNumber = t.Table.Number;
         if (t.Table.Location != null)
         {
             LocationId   = t.Table.Location.Id;
             LocationName = t.Table.Location.Name;
         }
     }
     //if (t.Table != null) {Table = new TableTabVM(t.Table); }
     if (t.Client != null)
     {
         Client = new UserTabVM(t.Client, t.Client.Sex, t.Client.File);
     }
 }