Monday, 29 August 2016

Upload image from mobile

No comments
HTML

<script id="my-modal.html" type="text/ng-template">
    <ion-modal-view class="ion-nifty-modal">
        <div class="ion-modal-content-custom">
            <ion-content class="padding">
                <div id="dvGallery" style="border-bottom: 1px solid #f1f1f1;" ng-click="getPhoto();">                  
                    <img src="img/gallery.png" style="padding: 20px 20px;cursor: pointer;height: 100px;" />
                    <h3 style="display:inline;display: inline;margin-top: 35px;position: absolute;color: white;">Gallery</h3>
                </div>
                <div>&nbsp;</div>
                <div id="dvCamera" ng-click="capturePhoto();">
                    <img src="img/camera.png" style="padding: 20px 20px;cursor: pointer;height: 100px;" />
                    <h3 style="display:inline;    display: inline;margin-top: 35px;position: absolute;color: white;">Camera</h3>                  
                </div>
            </ion-content>
        </div>
    </ion-modal-view>

</script>

<ion-view view-title="Me" hide-nav-bar="true" hide-back-button="true">
    <ion-content class="post-content has-header has-subheader" delegate-handle="mainScroll">
        <div id="content">
            <div id="profile-info">              
                <canvas id="imgUser" class="divImage img-circle" style="display:none" ng-click="openModal(class)" ></canvas>              
                <img id="profile-image" class="profileImage" ng-click="openModal(class)" ng-src="http://www.healthcare4free.com/{{profile.userimageurl}}">
                <h3 id="profile-name">{{profile.firstname==null?profile.Email:profile.firstname}}</h3>
            </div>
        </div>    
    </ion-content>
</ion-view>

Controller

controller('UserProfileCtrl', ['$state', '$scope', 'RequestData', '$ionicLoading', '$ionicModal', function ($state, $scope, RequestData, $ionicLoading, $ionicModal) {
    //Model popup class define
    $scope.modalClasses = ['slide-in-up', 'slide-in-down', 'fade-in-scale', 'fade-in-right', 'fade-in-left', 'newspaper', 'jelly', 'road-runner', 'splat', 'spin', 'swoosh', 'fold-unfold'];
    //On successfully uploading image from gallry or camera
    $scope.onPhotoURISuccess = function (imageURI) {
        var canvas = document.getElementById("imgUser");
        var ctx = canvas.getContext("2d");
        var cw = canvas.width;
        var ch = canvas.height;
        var maxW = 200;
        var maxH = 200;
        var img = new Image;
        img.onload = function () {
            var iw = img.width;
            var ih = img.height;
            var scale = Math.min((maxW / iw), (maxH / ih));
            var iwScaled = iw * scale;
            var ihScaled = ih * scale;
            canvas.width = iwScaled;
            canvas.height = ihScaled;
            ctx.drawImage(img, 0, 0, iwScaled, ihScaled);
            var dataURL = canvas.toDataURL("image/jpeg");
            base64(dataURL.slice(22, dataURL.length));
        }      
        img.src = "data:image/jpeg;base64," + imageURI;      
        $('#imgUser').css('display', 'block');
        $('.profileImage').css('display', 'none');

     
        $scope.closeModal();
    }
    //get photo from galary
    $scope.getPhoto = function () {
        navigator.camera.getPicture($scope.onPhotoURISuccess, $scope.onFail, {
            quality: 50,
            destinationType: destinationType.DATA_URL,
            sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
        });
    }
    //capturing photo from camera
    $scope.capturePhoto = function () {
        navigator.camera.getPicture($scope.onPhotoURISuccess, $scope.onFail, {
            quality: 50,
            destinationType: destinationType.DATA_URL
        });
    }
    //on fail of capturing or selecting image from camera
    $scope.onFail = function (message) {
        alert(message);
    }
    //open popup model
    $scope.openModal = function (animation) {
        $ionicModal.fromTemplateUrl('my-modal.html', {
            scope: $scope,
            animation: animation
        }).then(function (modal) {
            $scope.modal = modal;
            $scope.modal.show();
        });
    };
    //close popup model
    $scope.closeModal = function () {
        $scope.modal.hide();
    };
    //Cleanup the modal when we're done with it!
    $scope.$on('$destroy', function () {
        $scope.modal.remove();
    });
    // Execute action on hide modal
    $scope.$on('modal.hidden', function () {
        // Execute action
    });
    // Execute action on remove modal
    $scope.$on('modal.removed', function () {
        // Execute action
    });
    var userId = JSON.parse(sessionStorage.UserData).UserId;
    $ionicLoading.show();
    $scope.updateUser= function ()
    {
        var canvasUser = document.getElementById("imgUser");
        var pass = canvasUser.toDataURL();
        if (pass.length > 0) {
            pass = pass.replace(/data:image\/jpeg;base64,/g, '');
            pass = pass.replace(/data:image\/png;base64,/g, '');
        }
        var promisePost= SetData.updateProfile(userId, pass);


    }


//WebAPi

 #region SaveImage
                    var bytes = Convert.FromBase64String(userResult.File);
                    string path = System.Web.HttpContext.Current.Server.MapPath("~/UserImages") + "\\" + users.UserId;

                    if (!System.IO.Directory.Exists(path))
                        System.IO.Directory.CreateDirectory(path);

                    using (var ms = new MemoryStream(bytes, 0, bytes.Length))
                    {
                        Image image = Image.FromStream(ms, true);
                        image.Save(path + "\\" + "profile.png", System.Drawing.Imaging.ImageFormat.Png);
                    }

                    #endregion

//For Ionic Model

<link href="nifty.modal.css" rel="stylesheet" />

//Model Css


.ion-nifty-modal {
  width: 90%;
  min-height: 0 !important;
  height: 300px !important;
  top: 25%;
  left: 5%;
  right: 5%;
  bottom: 5%;
  background-color: transparent;
  border-radius: 10px;
  -webkit-box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5); }

.ion-nifty-modal .ion-modal-content-custom {
  width: 100%;
  height: 100%;
  color: #FFF;
  background-color: #333;/*white;*/
  border-radius: 10px; }

/* Fix modal backdrop for smaller devices */
@media (max-width: 679px) {
  .active .modal-backdrop-bg {
    opacity: .5; }
  .modal-backdrop-bg {
    -webkit-transition: opacity 300ms ease-in-out;
    transition: opacity 300ms ease-in-out;
    background-color: #000;

    opacity: 0; } }
read more

Friday, 26 August 2016

Search Data From Whole Table without knowing column

No comments
CREATE  PROCEDURE [dbo].[sp_FindStringInTable]
(
 @PageSize INT = NULL,
 @CurrentPage INT,        
 @stringToFind VARCHAR(100),
 @table sysname,
 @type varchar(100),
 @columnTypeName varchar(100)  
)
AS


DECLARE @sqlCommand VARCHAR(8000)
DECLARE @where VARCHAR(8000)
DECLARE @columnName sysname
DECLARE @cursor VARCHAR(8000)
DECLARE @Skip INT
DECLARE @Take INT

 IF(LEN(@type)<=0)
  BEGIN
   SET @type=NULL
  END
 IF(LEN(@columnTypeName)<=0)
  BEGIN
   SET @columnTypeName=NULL
  END

 SET @Skip = (@CurrentPage - 1) * @PageSize
SET @Take = @CurrentPage * @PageSize


BEGIN TRY

   SET @sqlCommand = 'SELECT *,(select typeName from address_types where address_types.type_id=A.type_id) as typeName
   FROM
   (SELECT ROW_NUMBER() OVER
   (ORDER BY add_id desc) rownumber,* FROM [' + @table + '] WHERE'
   SET @where = ''  
   SET @cursor = 'DECLARE col_cursor CURSOR FOR SELECT COLUMN_NAME
   FROM ' + DB_NAME() + '.INFORMATION_SCHEMA.COLUMNS WHERE  
    TABLE_NAME = ''' + @table + '''
   AND DATA_TYPE IN (''char'',''nchar'',''ntext'',''nvarchar'',''text'',''varchar'')'  

   EXEC (@cursor)

   OPEN col_cursor  
   FETCH NEXT FROM col_cursor INTO @columnName  

   WHILE @@FETCH_STATUS = 0  
   BEGIN  
       IF @where <> ''
           SET @where = @where + ' OR'

       SET @where = @where + ' [' + @columnName + '] LIKE ''%' + @stringToFind + '%'''
  IF(LEN(@columnTypeName)>0)
    BEGIN
  SET @where=@where+' AND '+@columnTypeName+'='+COALESCE(@type,'[type_id]')+''
     END  
       FETCH NEXT FROM col_cursor INTO @columnName  
   END  

   CLOSE col_cursor  
   DEALLOCATE col_cursor

   SET @sqlCommand = @sqlCommand + @where +') A WHERE
   A.RowNumber > ' + Cast(@Skip AS VARCHAR) + ' AND A.RowNumber <= '+cast(@Take as varchar)
 
   EXEC (@sqlCommand)
END TRY
BEGIN CATCH
   PRINT 'There was an error. Check to make sure object exists.'
   PRINT error_message()
   
   IF CURSOR_STATUS('variable', 'col_cursor') <> -3
   BEGIN
       CLOSE col_cursor  
       DEALLOCATE col_cursor
   END
END CATCH
read more

Wednesday, 24 August 2016

Dynamic sql query

No comments
CREATE procedure [dbo].[GetAll]
(
@countryId int,
@Title varchar(max),
@City varchar(max),
@MinimumInvestment int=null,
@MaximumInvestment int=null,
@InvestorRoleId int,
@GrowthStage varchar(max)
)
as
begin
declare @Query varchar(max)
set @Query ='
 select * from [dbo].[Opportunities]
where
CountryId =isnull('+case when @countryId is null then 'NULL' else cast(@countryId as varchar) end+',CountryId)
and City  like isnull('+case when @City is null then 'NULL' else cast(@City  as varchar) end+',City)
and Title  like isnull('''+case when @Title is null then 'NULL' else cast(@Title as varchar) end+''',Title)
and MinimumInvestment>=isnull('+case when @MinimumInvestment is null then 'NULL' else cast(@MinimumInvestment  as varchar) end+',MinimumInvestment)
and MaximumInvestment>=isnull('+case when @MaximumInvestment is null then 'NULL' else cast(@MaximumInvestment  as varchar) end+',MaximumInvestment)
and InvestorRoleId = '+cast(@InvestorRoleId as varchar) +'
and GrowthStageId in ('+case when @GrowthStage is null then 'GrowthStageId' else @GrowthStage end+')'

execute(@Query)
end
read more

Tuesday, 23 August 2016

Pagination in mvc with sql with Jquery datatable sorting

No comments
SQL




CREATE PROCEDURE soFoo
(
@PageSize INT = NULL,
@CurrentPage INT,      
@firstname VARCHAR(50),
@lastname VARCHAR(50),
@providerid int,
@clientid int ,
@patientChart  VARCHAR(50) ,
@status int
)
AS
BEGIN

    DECLARE @Skip INT
    DECLARE @Take INT    
    DECLARE @SQL VARCHAR(MAX)

if(@providerid <= 0)
    BEGIN
SET @providerid =null
    END
if(@status < 0)
    BEGIN
SET @status=null
    END


IF(LEN(@lastname)=0)
BEGIN
 SET @lastname=null
END
else
begin
SET @lastname='%'+@lastname+'%'
end

SET @Skip = (@CurrentPage - 1) * @PageSize
    SET @Take = @CurrentPage * @PageSize
 
 
    SELECT *,(select statename from states where states.stateid=A.stateid) as statename  FROM (SELECT ROW_NUMBER() OVER
( ORDER BY IsActive desc) rownumber,*
from Patient
where isnull(firstname,'') like coalesce(@firstname,firstname,'')
and isnull(lastname,'') like coalesce(@lastname,lastname,'')
and patientChart = coalesce(@patientChart,patientChart,'')
and IsActive=coalesce(@status,IsActive,'')
AND Patient.clientid=@clientid
) A
      WHERE A.RowNumber > @Skip AND A.RowNumber <= @Take  
END


Controller


 public void Get(Models models)
        {
            int _currentPage = 1;
            DateTime Fromdate = DateTime.Now;
            Fromdate = Fromdate.AddDays(-30);
            DateTime Todate = DateTime.Now;
            string lotno = string.Empty;
            int PageSize = 7;
            int printInId = 0;
            if (!string.IsNullOrEmpty(Request.QueryString["printInId"]))
            {
                if (IsInt(Request.QueryString["printInId"]))
                    printInId = Convert.ToInt32(Request.QueryString["printInId"]);
            }
            if (!int.TryParse(Request.QueryString["pg"], out _currentPage))
            {
                _currentPage = 1;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["fromDate"]))
            {
                Fromdate = Convert.ToDateTime(Request.QueryString["fromdate"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["toDate"]))
            {
                Todate = Convert.ToDateTime(Request.QueryString["toDate"]);
            }
models.CurrentPage = _currentPage;
            var relRepository = uow.Repository<RelRepository>();
            var result =RelRepository.ExecWithStoreProcedure("spView @PageSize,@CurrentPage,@FromDate,@ToDate,@lotno,@clientid,@printInId",
                new SqlParameter("PageSize", SqlDbType.Int) { Value = PageSize },
                new SqlParameter("CurrentPage", SqlDbType.Int) { Value = _currentPage },
                new SqlParameter("FromDate", SqlDbType.DateTime, 100) { Value = Fromdate },
                new SqlParameter("ToDate", SqlDbType.DateTime, 100) { Value = Todate },              
                new SqlParameter("printInId", SqlDbType.Int) { Value = printInId }
                ).ToList();

            models.TotalRecordCount = (RelRepository.ExecWithStoreProcedure("spViewCount @FromDate,@ToDate,@printInId",
                new SqlParameter("FromDate", SqlDbType.DateTime, 100) { Value = Fromdate },
                new SqlParameter("ToDate", SqlDbType.DateTime, 100) { Value = Todate },             
                new SqlParameter("printInId", SqlDbType.Int) { Value = printInId }
                ).FirstOrDefault().TotalRecordCount);


            int pageCount = models.TotalRecordCount / PageSize;
            pageCount = models.TotalRecordCount % PageSize > 0 ? pageCount + 1 : pageCount;
            models..TotalPageCount = pageCount;
            models..lstDrugIn = result;

VIEW

<div class="box">
                        <!-- /.box-header -->
                        <div class="box-body no-padding">
                            <div class="row col-md-12">
                                <div class="col-md-6 no-padding">                                   
                                    <div class="col-md-3 no-padding" style="padding-left: 5px !important;">
                                        <label>
                                            <input type="text" id="txtDatepickerFrom" class="form-control datePicker" placeholder="From Date" />
                                        </label>
                                    </div>
                                    <div class="col-md-3 no-padding" style="padding-left: 5px !important;">
                                        <label>
                                            <input type="text" id="txtDatepickerTo" class="form-control datePicker" placeholder="To Date" />
                                        </label>
                                    </div>                                   
                                </div>
                                <div class="col-md-6 no-padding">
                                    <div class="col-md-8"  style="padding-left: 5px !important;">
                                        <label style="width:100%">
                                            @Html.DropDownListFor(m => m.drugid, Model.DrugList, "Select Drug", new { @class = "chosen-select", id = "dropDrugName", name = "drpList" })
                                        </label>
                                    </div>
                                    <div class="col-md-4 no-padding">
                                        <label>
                                            <button class="btn btn-primary" id="btnSearch" onclick="SearchData('search');return false;">Search</button>
                                            <button class="btn btn-primary" id="btnReset" onclick="SearchData('reset');return false;">Reset</button>
                                        </label>
                                    </div>
                                </div>                                                                                            
                            </div>

                            <div class="clearfix">&nbsp;</div>

                            <div class="row col-sm-12">

                                <table id="tableView" class="table tablesorter">
                                    <thead>
                                        <tr>                                        
                                            <th class="textRight">
                                                Price
                                            </th>
                                            <th></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach (var item in @Model.lstDrugIn)
                                        {
                                            <tr>                                                
                                                <td style="text-align:right">@item.balanceqty</td>               
                                                <th class="col-md-2">
                                                </th>
                                            </tr>
                                        }
                                    </tbody>
                                </table>
                            </div>

                        </div>
                        <div class="box-footer">                           
                            <ul class="pagination pagination-sm no-margin pull-right">
                                @if (Model.CurrentPage > 1)
                                {
                                    <li>
                                        <a href="?pg=@(Model.CurrentPage > 1 ? (Model.CurrentPage - 1) : Model.CurrentPage)&fromDate=@(Request.QueryString["fromDate"] != null ? Request.QueryString["fromDate"] : "")&toDate=@(Request.QueryString["toDate"] != null ? Request.QueryString["toDate"] : "")">&laquo;</a>
                                    </li>
                                }
                                else
                                {
                                    <li class="disabled">
                                        <a href="javascript:void(0);">&laquo;</a>
                                    </li>
                                }
                                @if (Model.TotalPageCount > 0)
                                {
                                    for (int i = (Model.CurrentPage > 3 ? (Model.CurrentPage - 2) : 1); i < (Model.CurrentPage > 3 ? (Model.CurrentPage) + 3 : 6); i++)
                                    {
                                        if (Model.TotalPageCount >= i)
                                        {
                                            <li class="@(i == (Model.CurrentPage) ? "active" : "")">
                                                <a class="@(i == (Model.CurrentPage) ? "selected" : "")" href="?pg=@i&fromDate=@(Request.QueryString["fromDate"] != null ? Request.QueryString["fromDate"] : "")&toDate=@(Request.QueryString["toDate"] != null ? Request.QueryString["toDate"] : "")">@(i)</a>
                                            </li>
                                        }
                                    }
                                }
                                @if (Model.CurrentPage < Model.TotalPageCount)
                                {
                                    <li>
                                        <a href="?pg=@(Model.TotalPageCount == Model.CurrentPage ? (Model.TotalPageCount).ToString() : (Model.CurrentPage + 1).ToString())&fromDate=@(Request.QueryString["fromDate"] != null ? Request.QueryString["fromDate"] : "")&toDate=@(Request.QueryString["toDate"] != null ? Request.QueryString["toDate"] : "")">&raquo;</a>
                                    </li>
                                }
                                else
                                {
                                    <li class="disabled"><a href="javascript:void(0);">&raquo;</a></li>
                                }
                            </ul>
                        </div>
                        <!-- /.box-body -->
                    </div>


JQUERY


function getParameterByName(name) {
                name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
                var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
                    results = regex.exec(location.search);
                return results === null ? 0 : decodeURIComponent(results[1].replace(/\+/g, " "));
            }

 var drugName = getParameterByName('drugName');

                if (dateFrom.length > 0) {
                    $('#datepickerFrom').val(dateFrom);
                }


        $('#tableView').DataTable({
            "paging": false,
            "ordering": true,
            "info": false,
            "bFilter": false,
            "bInfo": false,
            "aaSorting": [[0, 'desc']]
        });
        $('#txtPrintInId').on('change', function () {           
            SearchData('Print');
        });
read more

Show loading screen in html page

No comments


Loading Image-

https://github.com/tajchert/WaitingDots/blob/master/images/dotsLoadingAnimation.gif

<div id="divLoading">
    </div>

To show

 $("#divLoading").addClass('show');

CSS


#divLoading
{
    display : none;
}
    #divLoading.show {
        display: block;
        position: fixed;
        z-index: 100;      
        background-image: url('../images/loading.gif');
        background-color: #666;
        opacity: 0.4;
        background-repeat: no-repeat;
        background-position: center;
        left: 0;
        bottom: 0;
        right: 0;
        top: 0;
    }
#loadinggif.show
{
    left : 50%;
    top : 50%;
    position : absolute;
    z-index : 101;
    width : 32px;
    height : 32px;
    margin-left : -16px;
    margin-top : -16px;
}
div.content {
   width : 1000px;
   height : 1000px;

}
read more

Friday, 19 August 2016

Bind Question-Answers inside ng-repeat

No comments
HTML

<div ng-repeat="(key, value) in HrqQuestions| groupBy: 'fullquestion'">
<div style="" class="list card normal">
<div class="item item-body item-divider" style="font-size: 26px !important;background-color: #28a54c;color: white;">
<p style="font-size: 20px;line-height: 25px;color: white;">{{key}}</p>        
</div>
<div ng-repeat="hrq in value">
<ion-item class="item-checkbox">
<label class="checkbox">
<input type="checkbox" ng-model="hrq.checked" ng-value="hrq.AnswerID" ng-click="selectedAnswer($index,HrqQuestions,hrq.AnswerID,hrq.Answer)" >
</label>
                            {{ hrq.Answer}}
</ion-item>

</div>
</div>
</div>


Json

{Answer:"White",AnswerID:967,answer_type:"RADIO",fullquestion:"Your Race",id:6}{Answer:"African American",AnswerID:968,answer_type:"RADIO",fullquestion:"Your Race",id:6}{Answer:"Asian",AnswerID:969,answer_type:"RADIO",fullquestion:"Your Race",id:6}
read more

Single checkable checkbox-angularjs

No comments
Html

<ion-item class="item-checkbox">
    <label class="checkbox">
   <input type="checkbox" ng-model="hrq.checked" ng-value="hrq.AnswerID" ng-  click="selectedAnswer($index,HrqQuestions,hrq.AnswerID,hrq.Answer)" >
   </label>
{{ hrq.Answer}}

</ion-item>


Js


$scope.selectedAnswer = function (position, questions, answerId, answer) {            
        angular.forEach(questions, function (subscription, index) {
            if (position != index)
                subscription.checked = false;
            $scope.selected = answerId;
        }
        );

    }
read more

Wednesday, 17 August 2016

Get matching text from any table with column name

No comments
CREATE PROCEDURE [dbo].[sp_FindStringInTable]
(
@stringToFind VARCHAR(100),
@table sysname,
@type varchar(100),
@columnTypeName varchar(100)
)
AS
DECLARE @take INT
DECLARE @sqlCommand VARCHAR(8000)
DECLARE @where VARCHAR(8000)
DECLARE @columnName sysname
DECLARE @cursor VARCHAR(8000)
DECLARE @whereColumn VARCHAR(100)
IF(LEN(@type)<=0)
BEGIN
SET @type=NULL
END
IF(LEN(@columnTypeName)<=0)
BEGIN
SET @columnTypeName=NULL
END

BEGIN TRY
   SET @sqlCommand = 'SELECT * FROM [' + @table + '] WHERE'
   SET @where = ''
   SET @whereColumn=''  
   SET @cursor = 'DECLARE col_cursor CURSOR FOR SELECT COLUMN_NAME
   FROM ' + DB_NAME() + '.INFORMATION_SCHEMA.COLUMNS WHERE  
    TABLE_NAME = ''' + @table + '''
   AND DATA_TYPE IN (''char'',''nchar'',''ntext'',''nvarchar'',''text'',''varchar'')'  

   EXEC (@cursor)

   OPEN col_cursor  
   FETCH NEXT FROM col_cursor INTO @columnName  

   WHILE @@FETCH_STATUS = 0  
   BEGIN  
       IF @where <> ''
           SET @where = @where + ' OR'

       SET @where = @where + ' [' + @columnName + '] LIKE ''%' + @stringToFind + '%'''
IF(LEN(@columnTypeName)>0)
  BEGIN
SET @where=@where+' AND '+@columnTypeName+'='+COALESCE(@type,'[type_id]')+''
   END
  PRINT @where
       FETCH NEXT FROM col_cursor INTO @columnName  
   END  

   CLOSE col_cursor  
   DEALLOCATE col_cursor

   SET @sqlCommand = @sqlCommand + @where --+@whereColumn
   PRINT @sqlCommand
   EXEC (@sqlCommand)
END TRY
BEGIN CATCH
   PRINT 'There was an error. Check to make sure object exists.'
   PRINT error_message()
   
   IF CURSOR_STATUS('variable', 'col_cursor') <> -3
   BEGIN
       CLOSE col_cursor  
       DEALLOCATE col_cursor
   END
END CATCH 
read more

Friday, 12 August 2016

Automapper to map model with entity -mvc

No comments

AutoMapper.Mapper.CreateMap<Contacts, SearchAddressModel>();
var searchAddressModelList = AutoMapper.Mapper.Map<List<SearchAddressModel>>(result);

read more

Saturday, 6 August 2016

Bind static dropdownlist in MVC

No comments
Model


public string patientStatus { get; set; }
public List<SelectListItem> Status
        {
            get {
                return new List<SelectListItem>
                {
                    new SelectListItem { Text="All",Value="All"},
                    new SelectListItem { Text="Active",Value="Active"},
                    new SelectListItem { Text="In Active",Value="In Active"}
                };
            }

        }


@Html.DropDownListFor(x => x.patientStatus, Model.Status, new { @class="form-control"})                                            
read more