Friday 24 June 2016

Example of NG-GRID in MVC & ANGULARJS

web api code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebApplication22.Models;
namespace WebApplication22.Controllers
{
   
    public class ValuesController : ApiController
    {
        public List<EMP> Gets()
        {

            using(Database1Entities obj=new Database1Entities())
            {
                return obj.EMPs.ToList();
            }
        }
        public EMP Get(int EID)
        {
            using (Database1Entities obj = new Database1Entities())
            {
                return obj.EMPs.SingleOrDefault(m => m.EID == EID);
            }
        }
        [HttpPost]
        public string Post(EMP emp)
        {
            using (Database1Entities obj = new Database1Entities())
            {
                obj.EMPs.Add(emp);
                obj.SaveChanges();
                return "Data Saved.";
            }
        }
        [HttpPut]
        public string Put(EMP emp)
        {
            using (Database1Entities obj = new Database1Entities())
            {
                EMP emp1 = obj.EMPs.SingleOrDefault(m => m.EID == emp.EID);
                emp1.NAME = emp.NAME;
                obj.SaveChanges();
                return "Data Updated.";
            }
        }
        [HttpPatch]
        public string Delete(EMP emp)
        {
            using (Database1Entities obj = new Database1Entities())
            {
                EMP emp1 = obj.EMPs.SingleOrDefault(m => m.EID == emp.EID);
                obj.EMPs.Remove(emp1);
                obj.SaveChanges();
                return "Data Deleted.";
            }
        }
    }
}

View Code :


@{
    ViewBag.Title = "Index";
}
<style type="text/css">
    .gridStyle {
        border: 1px solid rgb(212,212,212);
        width: 900px;
        height: 300px;
    }
</style>
<link href="~/Content/bootstrap.css" rel="stylesheet" />
<link href="~/Content/ng-grid.min.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script src="~/Scripts/angular.js"></script>
<script src="~/Scripts/ng-grid.js"></script>
<h2>Jay Jagannath...</h2>
<div class="container" ng-app="app" ng-controller="ctr">
    <form class="form-horizontal">
        <div class="form-group">
            <label class="control-label col-lg-4">EID</label>
            <div class="col-lg-4">
                <input type="text" class="form-control" ng-model="EMP.EID" id="tb" />
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-lg-4">NAME</label>
            <div class="col-lg-4">
                <input type="text" class="form-control" ng-model="EMP.NAME" />
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-lg-4"></label>
            <div class="col-lg-4">
                <input type="button" class="btn btn-primary" value="Save" style="width:80px" ng-click="save()" />
                <input type="button" class="btn btn-primary" value="Update" style="width:80px" ng-click="update()" />
                <input type="button" class="btn btn-primary" value="Reset" style="width:80px" ng-click="reset()" />
            </div>
        </div>
        <div class="gridStyle" ng-grid="gridOptions">

        </div>
    </form>
</div>
<script type="text/javascript">
    var app = angular.module("app", ['ngGrid']);
    app.controller("ctr", function ($scope,$http) {
        var m;
        function CLR()
        {
            $scope.EMP = new emp();
        } CLR();
        function fill()
        {
            $scope.filterOptions = {
                filterText: "",
                useExternalFilter: false
            };
            $scope.totalServerItems = 0;
            $scope.pagingOptions = {
                pageSizes: ['5','10','20'],
                pageSize: '5',
                currentPage: 1
            };
            $scope.setPagingData = function (data, page, pageSize) {
                var pagedData = data.slice((page - 1) * pageSize, page * pageSize);
                $scope.DataSource = pagedData;
                $scope.totalServerItems = data.length;
                if (!$scope.$$phase) {
                    $scope.$apply();
                }
            };
            $scope.getPagedDataAsync = function (pageSize, page, searchText) {
                setTimeout(function () {
                    var data;
                    if (searchText) {
                        var ft = searchText.toLowerCase();
                        $http.get('http://localhost:50628/api/Values').success(function (largeLoad) {
                            data = largeLoad.filter(function (item) {
                                return JSON.stringify(item).toLowerCase().indexOf(ft) != -1;
                            });
                            $scope.setPagingData(data, page, pageSize);
                        });
                    } else {
                        $http.get('http://localhost:50628/api/Values').success(function (largeLoad) {
                            $scope.setPagingData(largeLoad, page, pageSize);
                        });
                    }
                }, 100);
            };

            $scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage);

            $scope.$watch('pagingOptions', function (newVal, oldVal) {
                if (newVal !== oldVal && newVal.currentPage !== oldVal.currentPage) {
                    $scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage, $scope.filterOptions.filterText);
                }
            }, true);
            $scope.$watch('filterOptions', function (newVal, oldVal) {
                if (newVal !== oldVal) {
                    $scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage, $scope.filterOptions.filterText);
                }
            }, true);


            $scope.gridOptions = {
                data: 'DataSource',
                multiSelect: false,
                enableCellEdit: false,
                enableRowSelection: true,
                enableColumnResize: false,
                enableCellSelection: false,
                enablePaging: true,
                showFooter: true,
                totalServerItems: 'totalServerItems',
                pagingOptions: $scope.pagingOptions,
                filterOptions: $scope.filterOptions,
                showFilter: true,
                columnDefs:
                 [
          { field: 'EID', displayName: 'Eid', width: '250px', resizable: true },
          { field: 'NAME', displayName: 'Name', width: '250px' },
          
       {
           displayName: 'Actions', cellTemplate:
            '<div class="grid-action-cell">' +
            '<a ng-click="Edit(row.entity);" >Edit</a>' + ' | ' +
            '<a ng-click="Del(row.entity);" >Delete</a>' +
            '</div>'
       }
                 ],
            };

            
        } fill();
        $scope.save = function ()
        {
            m = $http({
                url: 'http://localhost:50628/api/Values/Post',
                method: 'Post',
                data:$scope.EMP
            });
            m.then(function (d) {
                alert(d.data);
                CLR();
                fill();
            });
        }
        $scope.update = function () {
            m = $http({
                url: 'http://localhost:50628/api/Values/Put',
                method: 'Put',
                data: $scope.EMP
            });
            m.then(function (d) {
                alert(d.data);
                CLR();
                fill();
            });
        }
        $scope.Edit = function (s)
        {
          
            m = $http({
                url: 'http://localhost:50628/api/Values/Get?EID='+s.EID,
                method: 'Get',
                
            });
            m.then(function (d) {
               
                $scope.EMP = d.data;
            });
        }
        $scope.reset = function () {
            CLR();
        }
        $scope.Del = function (s) {

            if (confirm('Do you want to delete it ?'))
            {
                m = $http({
                    url: 'http://localhost:50628/api/Values/Delete',
                    method: 'Patch',
                    data: s
                });
                m.then(function (d) {
                    alert(d.data);
                    fill();
                   
                });
            }
        }
    });
    function emp()
    {
        return {
            EID: null,
            NAME:null
        }
    }
</script>

Monday 20 June 2016

CURD oration in ng grid using angular js,MVC,web API

web api Code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebApplication21.Models;

namespace WebApplication21.Controllers
{
   
    public class ValuesController : ApiController
    {
        public List<string> Getc()
        {
            using (Database1Entities obj = new Database1Entities())
            {
                return obj.COUNTRies.Select(m => m.CNAME).ToList();
            }
        }
        public List<string> Gets(string CNAME)
        {
            using (Database1Entities obj = new Database1Entities())
            { 
                int i=obj.COUNTRies.FirstOrDefault(m=>m.CNAME==CNAME).CID;
                return obj.STATEs.Where(m => m.CID == i).Select(n => n.SNAME).ToList();
            }
        }
        public List<EMP> Gete(int i, int j)
        {
            using (Database1Entities obj = new Database1Entities())
            {
                return obj.EMPs.ToList();
            }
        }
        public EMP GetById(int EID, int i, int j)
        {
            using(Database1Entities obj=new Database1Entities())
            {
                return obj.EMPs.SingleOrDefault(m => m.EID == EID);
            }
        }
        [HttpPost]
        public string Post(EMP emp)
        {
            using (Database1Entities obj = new Database1Entities())
            {
                obj.EMPs.Add(emp);
                obj.SaveChanges();
                return "Data Saved.";
            }
        }
        [HttpPut]
        public string Put(EMP emp)
        {
            using (Database1Entities obj = new Database1Entities())
            {
                EMP emp1 = obj.EMPs.SingleOrDefault(m => m.EID == emp.EID);
                emp1.NAME = emp.NAME;
                emp1.ADDRESS = emp.ADDRESS;
                emp1.PASSWORD = emp.PASSWORD;
                emp1.GENDER = emp.GENDER;
                emp1.ISMARRIED = emp.ISMARRIED;
                emp1.CNAME = emp.CNAME;
                emp1.SNAME = emp.SNAME;
                obj.SaveChanges();
                return "Data Updated.";
            }
        }
        [HttpPatch]
        public string Delete(EMP emp)
        {
            using (Database1Entities obj = new Database1Entities())
            {
                EMP emp1 = obj.EMPs.SingleOrDefault(m => m.EID == emp.EID);
                obj.EMPs.Remove(emp1);
                obj.SaveChanges();
                return "Data Deleted.";
            }
        }

    }
}

View code
@{
    ViewBag.Title = "Index";
}
<style type="text/css">
    .gridStyle {
        border: 1px solid rgb(212,212,212);
        width: 900px;
        height: 300px;
    }
</style>
<h2>JAY JAGANNATH...</h2>
<link href="~/Content/bootstrap.css" rel="stylesheet" />
<link href="~/Content/ng-grid.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script src="~/Scripts/angular.js"></script>
<script src="~/Scripts/ng-grid.js"></script>

<script type="text/javascript">
    var app = angular.module('App', ['ngGrid']);
    app.controller('Ctr', function ($scope, $http) {
        var m;
        function CLR() {
            $scope.EMP = new emp();
            $('#tb').focus();
        } CLR();
        function fill() {
            m = $http({
                url: 'http://localhost:64633/api/values/Gete?i=' + 1 + '&j=' + 2,
                method: 'Get'
            });
            m.then(function (d) {
                $scope.DataSource = d.data;
            });
            
           
          
            $scope.gridOptions = {
                multiSelect: false,
                enableCellEdit: false,
                enableRowSelection: true,
                enableColumnResize: false,
                enableCellSelection: false,
                showFilter: true,
                columnDefs:
                    [
             { field: 'EID', displayName: 'Eid', width: '250px', visible: false, resizable: true },
             { field: 'NAME', displayName: 'Name', width: '250px' },
             { field: 'ADDRESS', displayName: 'Address', width: '350px' },
              { field: 'GENDER', displayName: 'Gender', width: '100px' },
          {
              displayName: 'Actions', cellTemplate:
               '<div class="grid-action-cell">' +
               '<a ng-click="Edit(row.entity);" >Edit</a>' + ' | ' +
               '<a ng-click="Del(row.entity);" >Delete</a>' +
               '</div>'
          }
                    ],
                data: 'DataSource',

            };
        } fill();

        $scope.save = function () {
            m = $http({
                url: 'http://localhost:64633/api/values/Post',
                method: 'Post',
                data: $scope.EMP
            });
            m.then(function (d) {
                alert(d.data);
                CLR();
                fill();
            });
        }
        $scope.update = function () {
            m = $http({
                url: 'http://localhost:64633/api/values/Put',
                method: 'Put',
                data: $scope.EMP
            });
            m.then(function (d) {
                alert(d.data);
                CLR();
                fill();
            });
        }
        $scope.reset = function () {
            CLR();
        }
        $scope.Del = function (s) {
            if (confirm('Do you want to delete it ?')) {
                m = $http({
                    url: 'http://localhost:64633/api/values/Delete',
                    method: 'Patch',
                    data: s
                });
                m.then(function (d) {
                    alert(d.data);
                    fill();
                });
            }
        };
        m = $http({
            url: 'http://localhost:64633/api/values',
            method: 'Get'
        });
        m.then(function (d) {
            $scope.listc = d.data;
        });


        $scope.fillddl = function () {
            fd($('#ddl :selected').text());
        }
        function fd(s) {

            m = $http({
                url: 'http://localhost:64633/api/values/Gets?CNAME=' + s,
                method: 'Get'
            });
            m.then(function (d) {

                $scope.lists = d.data;
            });
        }
        $scope.Edit = function (s) {
            fd(s.CNAME);
            $scope.EMP = s;
        }
    });
    function emp() {
        return {
            EID: null,
            NAME: null,
            ADDRESS: null,
            PASSWORD: null,
            GENDER: null,
            ISMARRIED: true,
            CNAME: null,
            SNAME: null
        }
    }
</script>
<div class="container" ng-app="App" ng-controller="Ctr">
    <form class="form-horizontal">
        <div class="form-group">
            <label class="col-lg-4 control-label">EID</label>
            <div class="col-lg-4">
                <input type="text" class="form-control" ng-model="EMP.EID" id="tb" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-4 control-label">NAME</label>
            <div class="col-lg-4">
                <input type="text" class="form-control" ng-model="EMP.NAME" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-4 control-label">ADDRESS</label>
            <div class="col-lg-4">
                <textarea class="form-control" ng-model="EMP.ADDRESS"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-4 control-label">PASSWORD</label>
            <div class="col-lg-4">
                <input type="password" class="form-control" ng-model="EMP.PASSWORD" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-4 control-label">GENDER</label>
            <div class="col-lg-4">
                <input type="radio" ng-model="EMP.GENDER" value="Male" />Male
                <input type="radio" ng-model="EMP.GENDER" value="Female" />Female
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-4 control-label">ARE YOU MARRIED ?</label>
            <div class="col-lg-4">
                <input type="checkbox" ng-model="EMP.ISMARRIED" />
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-lg-4">COUNTRY</label>
            <div class="col-lg-4">
                <select class="form-control" id="ddl" ng-model="EMP.CNAME" ng-change="fillddl()" ng-options="c for c in listc"></select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-4 control-label">STATE</label>
            <div class="col-lg-4">
                <select class="form-control" ng-model="EMP.SNAME" ng-options="c for c in lists"></select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-4 control-label"></label>
            <div class="col-lg-4">
                <input type="button" value="Save" style="width:80px" ng-click="save()" class="btn btn-primary" />
                <input type="button" value="Update" style="width:80px" ng-click="update()" class="btn btn-primary" />
                <input type="button" value="Reset" style="width:80px" ng-click="reset()" class="btn btn-primary" />
            </div>
        </div>
        <div class="gridStyle " ng-grid="gridOptions">
        </div>
    </form>
</div>



Monday 13 June 2016

How to read text file in MVC

using System.Transactions;
using System.IO;
 
 public ActionResult Save(B2CFileUpload b2CFileUpload)
        {
            if (b2CFileUpload.Upload.ContentType.Trim() == "text/plain".Trim())
            {
                try
                {
                    using (var scope = new System.Transactions.TransactionScope(TransactionScopeOption.Required, TimeSpan.FromSeconds(300)))
                    {

                   
                        List<SalesOrderItem> lstSalesOrderItem = new List<SalesOrderItem>();
                        DirectoryInfo ActualFolder = new DirectoryInfo(Server.MapPath("~/Administration/Content/B2CFiles/"));
                        DirectoryInfo NewFolder = ActualFolder.CreateSubdirectory(DateTime.UtcNow.ToShortDateString().Replace('/', '-'));
                        b2CFileUpload.Upload.SaveAs(NewFolder.FullName + "/" + Path.GetFileName(b2CFileUpload.Upload.FileName));
                        StreamReader streamReader = new StreamReader(System.IO.File.OpenRead(NewFolder.FullName + "/" + Path.GetFileName(b2CFileUpload.Upload.FileName)));

                        while (!streamReader.EndOfStream)
                        {
                            string row = streamReader.ReadLine();
                            if (i == 0)
                            {
                                string[] Columns = row.Split('-');
                                string[] SalesTaxvalues = Columns[1].Split('.');
                                SalesTax = SalesTaxvalues[1].Substring(2, 6) + "." + SalesTaxvalues[2].Substring(0, 2);
                            }
                            else
                            {
                                string[] Columns = row.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                CustId = Columns[0];
                                ItemId = Columns[1].Substring(13);
                                string[] check = Columns[2].Split('.');
                                ItemPrice = check[0] + "." + check[1].Substring(0, 2);
                                //ItemQuantity = check[1].Substring(2, 6) + "." + check[2].Substring(0, 2);
                                ItemQuantity = check[1].Substring(2, 6);
                                LineTotal = check[2].Substring(2, 6) + "." + check[3].Substring(0, 3);
                             
                            }

                            i++;
                        }
                     
                        }
                        Invoice invoice = _invoiceService.InsertInvoice(invoiceModel.ToEntity());
                        TempData["Update"] = (i - 1);
                        TempData.Keep("Update");
                        scope.Complete();
                    }
                }
                catch (Exception ex)
                {
                    TempData["Error"] = ex.Message;
                    TempData.Keep("Error");
                }




            }
            return RedirectToAction("Index");
        }

Example of trigger for auto increment ID

ALTER TRIGGER [dbo].[CEBC_TRIGGER_UPDATE_INVOICE_NUMBER]
   ON [dbo].[Invoice]
AFTER INSERT
 
AS
BEGIN
DECLARE @INVOICE_NUMBER VARCHAR(MAX),@TEMP_NUMBER INT
SELECT @TEMP_NUMBER=MAX(SUBSTRING(invoiceNo,4, LEN(invoiceNo) -3)) FROM INVOICE
IF LEN(@TEMP_NUMBER)>0
BEGIN
SET @TEMP_NUMBER=@TEMP_NUMBER+1
SET @INVOICE_NUMBER='INV'+REPLICATE('0',(6-LEN(@TEMP_NUMBER)))+convert(varchar,@TEMP_NUMBER)
BEGIN TRY
BEGIN TRANSACTION
               BEGIN
UPDATE INVOICE
SET INVOICE.invoiceNo=@INVOICE_NUMBER
FROM [dbo].[Invoice]
INNER JOIN INSERTED  ON (INVOICE.Id = INSERTED.Id)
END
  COMMIT TRANSACTION
END TRY
BEGIN CATCH
PRINT ERROR_MESSAGE()
ROLLBACK TRANSACTION
END CATCH
END
ELSE
BEGIN
BEGIN TRY
BEGIN TRANSACTION
               BEGIN
UPDATE INVOICE
SET INVOICE.invoiceNo='INV000001'
FROM [dbo].[Invoice]
INNER JOIN INSERTED  ON (INVOICE.Id = INSERTED.Id)
END
  COMMIT TRANSACTION
END TRY
BEGIN CATCH
PRINT ERROR_MESSAGE()
ROLLBACK TRANSACTION
END CATCH
END


END

Wednesday 8 June 2016

How to read CSV file in MVC using/LumenWorksCsvReader

Install nugget package in user appliction

View


 

@{
    ViewBag.Title = "Index";
}
<br /><br /><br />
@using (Html.BeginForm("Save", "Home", FormMethod.Post, new { @enctype = "multipart/form-data" }))
{
    @Html.TextBox("fu", null, new { @type = "file" }) <br />
    <input type="submit" value="Save" />
}


Controller

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LumenWorks.Framework.IO.Csv;
using System.IO;

namespace WebApplication18.Controllers
{
    public class HomeController : Controller
    {
        // GET: Home
        public ActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Save(HttpPostedFileBase fu)
        {

            fu.SaveAs(Server.MapPath("~/File/" + System.IO.Path.GetFileName(fu.FileName)));
            Readcsv(Server.MapPath("~/File/" + System.IO.Path.GetFileName(fu.FileName)));
            return RedirectToAction("Index");
        }
        public void Readcsv(string Path)
        {
            using (CsvReader csv = new CsvReader(
                   new StreamReader(Path), true, '\t', '\0', '\0', '#', ValueTrimmingOptions.All))
            {
                csv.MissingFieldAction = MissingFieldAction.ReplaceByNull;
                string[] headers = csv.GetFieldHeaders();
                while (csv.ReadNextRecord())
                {
                    var y = csv[0];
                    for (int i = 0; i < csv.FieldCount; i++)
                    {
                        var x = csv[i];
                    }
                        
                }
            }
        }
    }
}

Monday 6 June 2016

Example of kendo multiple file upload control

 @using (Html.BeginForm("Save", "Banner", FormMethod.Post, new { @enctype = "multipart/form-data", @id = "frmAddImage" }))
    {
        @Html.AntiForgeryToken()

        <div class="col-lg-12 zero-padding ">


            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
            @{
        if (Model.Mark == 1)
        {
            <div class="form-group" style="position:relative">

                @Html.LabelFor(model => model.PictureId, htmlAttributes: new { @class = "" })<span class="mandatory"><b>*</b></span>


                <div class="options documentUpload pull-left" style="margin-bottom:0!important; padding-bottom:0!important">

                    <div style="position:relative;margin-top:-48px">
  @Html.TextBoxFor(model => model.Pictures, new { @class = "form-control", @type = "file" })</div>
                    <div class="clearfix"></div>
                    <div style="position:relative; margin-top:30px"> @Html.ValidationMessageFor(model => model.PictureId, "", new { @class = "text-danger", @id = "lbPid" })</div>
                </div>

            </div>
        }
            }


<script type="text/javascript">
    $(function () {

        $("#Pictures").kendoUpload({
            multiple: true,
            select: onSelect
        });
 var m=0;
        function onSelect(e)
        {
            $.each(e.files, function (index, value) {
                if (value.extension.toLowerCase() == ".jpg"
                || value.extension.toLowerCase() == ".jpeg"
                || value.extension.toLowerCase() == ".png"
                || value.extension.toLowerCase() == ".gif"
                || value.extension.toLowerCase() == ".bmp")
                {
                    m = 0;

                }

                else {

                    m = 1;
                 

                }


            });
            if (m == 1)
            {
                $('#lbPid').text('Please upload valid picture .');
                $("#Pictures").focus();
            }
            else {
                $('#lbPid').text('');
            }

        }
// require validation
 if ($("#Pictures").data("kendoUpload").wrapper.find(".k-file").length == 0)
                {
                    $('#lbPid').text('Please select a Picture .');
                    check = 1;
                }
        $("#Title").focus(function(){
           var extension;
           $(".k-upload-files").find("li").each(function(i,j){
               extension =$(j).text().split(".");
                if(extension[1].toLowerCase() == ".jpg"
               || extension[1].toLowerCase() == ".jpeg"
               || extension[1].toLowerCase() == ".png"
               ||extension[1].toLowerCase() == ".gif"
               || extension[1].toLowerCase() == ".bmp")
               {}
                else
               {
                   $(j).remove();
               }
            });
        });
</script>


controller :

 public ActionResult Save(BannerVM bannerVM)
        {
            BannerModel bannerModel = new BannerModel();
         
                if (ModelState.IsValid)
                {
//list<HttpPostedFileBase >  Pictures = new list<HttpPostedFileBase >();
                    foreach (HttpPostedFileBase ImageData in bannerVM.Pictures)
                    {
                        byte[] StoreData = new byte[ImageData.InputStream.Length];
                        ImageData.InputStream.Read(StoreData, 0, StoreData.Length);
                        bannerModel.Title = bannerVM.Title;
                        bannerModel.StatusID = bannerVM.StatusID;
                        bannerModel.DisplayOrder = (bannerVM.DisplayOrder == null ? 1 : bannerVM.DisplayOrder);
                        bannerModel.Description = bannerVM.Description;
                        bannerModel.PictureId = _pictureService.InsertPicture(StoreData, ImageData.ContentType, Path.GetFileName(ImageData.FileName), true).Id;
                        bannerModel.IsPublish = bannerVM.IsPublish;
                        bannerModel.CreatedBy = EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.Id;
                        bannerModel.CreatedDate = DateTime.UtcNow;
                        bannerModel.IsDeleted = bannerVM.IsDeleted;
                        _bannerService.SaveBanner(bannerModel.ToEntity());
                    }
                }