dimanche 19 novembre 2017

Single line if statement with one or more actions

I'd like to do a single line if statement with more than 1 action.

Default is this:

 @if (Reservation.Status == RSVStatusType.Cancelled)
                            {
                                <div class="row no-gutters alert-danger">
                                    <div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
                                        @Resource.Reservation_Status
                                    </div>
                                    <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                                        @Reservation.Status
                                    </div>                                           
                                </div>
                            }
                           else if (Reservation.Status == RSVStatusType.Booked)
                            {
                                <div class="row no-gutters alert-info">
                                    <div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
                                        @Resource.Reservation_Status
                                    </div>
                                    <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                                        @Reservation.Status
                                    </div>                                    
                                </div>
                            }

also i need to pass the alert-danger or alert-info css class depend on the action or condition .

i need some thing like that

   @(reservation.status == cancelled ? "danger" : "info")

any advice i tried more than way but i did bit get solution .

Aucun commentaire:

Enregistrer un commentaire