Ejemplo n.º 1
0
        public IActionResult PutVendorBusy([FromBody] VendorBusy vendorBusy)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                VendorBusy vendor = _context.vendorBusies.Where(a => a.Id == vendorBusy.Id).FirstOrDefault();
                /// vendor.Id = vendorBusy.Id;
                // vendor.vendor_id = vendorBusy.vendor_id;
                //vendor.BookingId = vendorBusy.BookingId;
                vendor.BusyDay = vendorBusy.BusyDay.Date;
                vendor.Reason  = vendorBusy.Reason;
                vendor.Status  = vendorBusy.Status;
                //_context.Entry(vendorBusy).State = EntityState.Modified;
                _context.SaveChanges();
                return(Ok(vendorBusy));
            }
            catch
            {
                return(BadRequest());
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> AddBook(Booking booking)
        {
            if (booking.RealDate > DateTime.Now)
            {
                if (ModelState.IsValid)
                {
                    booking.BookDate = DateTime.Now;
                    await _context.booking.AddAsync(booking);

                    await _context.SaveChangesAsync();

                    VendorBusy vendorBusy = new VendorBusy();
                    vendorBusy.vendor_id = booking.VendorId;
                    vendorBusy.BusyDay   = booking.RealDate;
                    vendorBusy.Reason    = "Book For " + booking.UserId;
                    vendorBusy.BookingId = booking.BookingId;
                    await _context.vendorBusies.AddAsync(vendorBusy);

                    await _context.SaveChangesAsync();

                    return(Ok(new { BusyDate = booking.RealDate.ToString("yyyy-MM-dd") }));
                }
                else
                {
                    return(NoContent());
                }
            }
            else
            {
                return(NotFound("You Must Select New Data"));
            }
        }
Ejemplo n.º 3
0
        public ActionResult PostVendorBusy([FromBody] VendorBusy vendorBusy)
        {
            //vendorBusy.id = 0;
            ///vendorBusy.vendor_id = "11A";
            // _context.Entry(vendorBusy).State = EntityState.Added;
            _context.vendorBusies.Add(vendorBusy);
            _context.SaveChanges();

            return(Ok());
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> EditBook(Booking booking)
        {
            Booking Book = await _context.booking.FindAsync(booking.BookingId);

            if (Book != null)
            {
                if (booking.RealDate > DateTime.Now)
                {
                    DateTime DateNow  = DateTime.Now;
                    DateTime RealDate = Book.RealDate;
                    double   NOofDays = (RealDate - DateNow).TotalDays;
                    if (NOofDays > 10)
                    {
                        Book.RealDate = booking.RealDate;

                        VendorBusy BusyDate = await _context.vendorBusies.Where(a => a.BookingId == booking.BookingId).SingleAsync();

                        BusyDate.BusyDay = booking.RealDate;
                        await _context.SaveChangesAsync();

                        return(Ok(new { BusyDate = booking.RealDate.ToString("yyyy-MM-dd") }));
                    }
                    else
                    {
                        return(NotFound("you can not Edit your"));
                    }
                }
                else
                {
                    return(NotFound("You Must Select new Data"));
                }
            }
            else
            {
                return(NoContent());
            }
        }