Ejemplo n.º 1
0
        public ResourceData <string> EnterVehicle(long entryDate, Vehicle vehicle)
        {
            var resourceData = new ResourceData <string>
            {
                _status = (int)StatusData.LOADING
            };

            try
            {
                resourceData._status  = (int)StatusData.SUCCESS;
                resourceData._message = ReceiptService.EnterVehicle(entryDate, vehicle);
            }
            catch (Exception e)
            {
                resourceData._status  = (int)StatusData.ERROR;
                resourceData._message = e.GetType() switch
                {
                    Type t when typeof(RealmDuplicatePrimaryKeyValueException).IsInstanceOfType(t) => Context.GetString(Resource.String.vehicle_already_in_the_parking_lot),
                    Type t when typeof(MaximunCantVehicleException).IsInstanceOfType(t) => Context.GetString(Resource.String.there_is_no_space_to_store_the_vehicle),
                    Type t when typeof(CanNotEnterVehicleException).IsInstanceOfType(t) => Context.GetString(Resource.String.you_cannot_enter_the_vehicle_since_it_is_not_sunday_or_monday),
                    _ => Context.GetString(Resource.String.something_unexpected_happened)
                };
            }

            return(resourceData);
        }