Ejemplo n.º 1
0
 // PUT: api/BookingLight/5
 public void Put(string id, [FromBody] BookingLight value)
 {
     try
     {
         BookingLightDAL.Update(id, value);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
 // POST: api/BookingLight
 public void Post([FromBody] BookingLight value)
 {
     try
     {
         BookingLightDAL.Insert(value);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public IActionResult BookLight()
 {
     try
     {
         BookingLight bookinglight = new BookingLight();
         bookinglight.LightList = _ILight.GetAllLight();
         bookinglight.LightType = "1";
         SetSlider();
         return(View(bookinglight));
     }
     catch (Exception)
     {
         throw;
     }
 }
 public int BookingLight(BookingLight bookinglight)
 {
     try
     {
         if (bookinglight != null)
         {
             _context.BookingLight.Add(bookinglight);
             _context.SaveChanges();
             return(bookinglight.BookLightID);
         }
         else
         {
             return(0);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public IActionResult BookLight(BookingLight bookinglight)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View("BookLight", bookinglight));
                }

                if (bookinglight != null && bookinglight.LightList != null)
                {
                    var result          = 0;
                    var validateChecked = 0;

                    for (int i = 0; i < bookinglight.LightList.Count(); i++)
                    {
                        if (bookinglight.LightList[i].LightChecked)
                        {
                            validateChecked = 1;


                            BookingLight objbookinglight = new BookingLight()
                            {
                                LightType       = bookinglight.LightType,
                                LightIDSelected = Convert.ToInt32(bookinglight.LightList[i].LightID),
                                BookingID       = Convert.ToInt32(HttpContext.Session.GetInt32("BookingID")),
                                Createdby       = Convert.ToInt32(HttpContext.Session.GetString("UserID")),
                                CreatedDate     = DateTime.Now
                            };
                            result = _IBookingLight.BookingLight(objbookinglight);
                        }
                    }

                    if (validateChecked == 0)
                    {
                        ModelState.AddModelError("", "You have not choose any Lighting !");
                    }

                    SetSlider();

                    if (result > 0)
                    {
                        ModelState.Clear();
                        ViewData["BookingLightingMessage"] = "Lighting Booked Successfully";
                        return(View("Success"));
                    }
                    else
                    {
                        return(View("BookLight", bookinglight));
                    }
                }
                else
                {
                    return(View("BookLight", bookinglight));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }