public JsonResult Edit(int id)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            try
            {
                switch (Request["entity"])
                {
                case "callout_room":

                    callout_room calloutRoom = _dbContext.callout_room.Find(id);
                    serializeToCalloutRoomModel(ref calloutRoom);
                    _dbContext.SaveChanges();
                    break;

                case "airticket":

                    airticket airticket = _dbContext.airtickets.Find(id);
                    serializeToAirticketModel(ref airticket);
                    _dbContext.SaveChanges();
                    break;

                case "transfer":

                    transfer transfer = _dbContext.transfers.Find(id);
                    serializeToTransferModel(ref transfer);
                    _dbContext.SaveChanges();
                    break;

                case "excursion_order":

                    excursion_order excursionOrder = _dbContext.excursion_order.Find(id);
                    serializeToExcursionOrderModel(ref excursionOrder);
                    _dbContext.SaveChanges();
                    break;

                case "hotel_service_order":

                    hotel_service_order hotelServiceOrder = _dbContext.hotel_service_order.Find(id);
                    serializeToHotelServiceOrderModel(ref hotelServiceOrder);
                    _dbContext.SaveChanges();
                    break;

                default:
                    throw new Exception("Error! Unexcepted entity");
                }

                _dbContext.SaveChanges();
            }
            catch (Exception exc)
            {
                result.Add("error", exc.Message);
            }

            return(Json(result, JsonRequestBehavior.DenyGet));
        }
        public JsonResult Delete(int id, string type)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            try
            {
                switch (type)
                {
                case "callout_room":

                    callout_room calloutRoom = _dbContext.callout_room.Find(id);
                    _dbContext.callout_room.Remove(calloutRoom);
                    _dbContext.SaveChanges();

                    break;

                case "airticket":

                    airticket airticket = _dbContext.airtickets.Find(id);
                    _dbContext.airtickets.Remove(airticket);
                    _dbContext.SaveChanges();
                    break;

                case "transfer":

                    transfer transfer = _dbContext.transfers.Find(id);
                    _dbContext.transfers.Remove(transfer);
                    _dbContext.SaveChanges();
                    break;

                case "excursion_order":

                    excursion_order excursionOrder = _dbContext.excursion_order.Find(id);
                    _dbContext.excursion_order.Remove(excursionOrder);
                    _dbContext.SaveChanges();
                    break;

                case "hotel_service_order":

                    hotel_service_order hotelServiceOrder = _dbContext.hotel_service_order.Find(id);
                    _dbContext.hotel_service_order.Remove(hotelServiceOrder);
                    _dbContext.SaveChanges();
                    break;

                default:
                    throw new Exception("Error! Unexcepted entity");
                }
            }
            catch (Exception exc)
            {
                result.Add("error", exc.Message);
            }

            return(Json(result, JsonRequestBehavior.DenyGet));
        }
        private void serializeToHotelServiceOrderModel(ref hotel_service_order hotelServiceOrder)
        {
            hotelServiceOrder.hotel_service_id = int.Parse(Request.Form["hotel_service_id"]);
            hotelServiceOrder.duration         = int.Parse(Request.Form["duration"]);
            hotelServiceOrder.provision_at     = Utils.dtToTimestamp(Convert.ToDateTime(Request.Form["provision_at"]));
            hotelServiceOrder.created_at       = Utils.dtToTimestamp(DateTime.Now);
            hotelServiceOrder.callout_id       = int.Parse(Request.Form["callout_id"]);

            hotel_service hotelService = _dbContext.hotel_service.Find(hotelServiceOrder.hotel_service_id);

            hotelServiceOrder.payment = hotelService.cost_per_min * hotelServiceOrder.duration;
        }