public static Vehicle GetDbModel(this VehicleViewModel viewModel)
 {
     return(new Vehicle
     {
         VehicleId = viewModel.VehicleId ?? 0,
         VehicleName = viewModel.VehicleName,
         Registration = viewModel.VehicleRegistration,
         Kilometers = (decimal)viewModel.VehicleKilometers
     });
 }
        public static CateringDetailModel GetCateringDetailModel(this Catering catering)
        {
            CateringDetailModel model = new CateringDetailModel
            {
                CateringId     = catering.CateringId,
                CateringName   = catering.CateringName,
                ClientName     = catering.ClientName,
                CateringDate   = catering.CateringDate.ToString("dd.MM.yyyy."),
                IsClosed       = catering.IsClosed,
                ClosingComment = catering.ClosingComment
            };

            if (catering.CateringEmployees != null)
            {
                model.Users = catering.CateringEmployees.Select(x => x.User.GetViewModel()).ToList();
            }

            if (catering.CateringDishes != null)
            {
                model.Dishes = catering.CateringDishes.Select(x => x.Dish.GetViewModel()).ToList();
            }

            if (catering.Vehicle != null)
            {
                model.Vehicles = new List <VehicleViewModel> {
                    catering.Vehicle.GetViewModel()
                };
            }
            else
            {
                VehicleViewModel vehicle = new VehicleViewModel
                {
                    VehicleId           = 0,
                    VehicleName         = "Bez vozila",
                    VehicleKilometers   = 0,
                    VehicleRegistration = ""
                };
                model.Vehicles = new List <VehicleViewModel> {
                    vehicle
                };
            }

            return(model);
        }