/// <summary>
        /// Gets the or create measure.
        /// </summary>
        /// <param name="measureId">The measure identifier.</param>
        /// <returns></returns>
        public MeasureModel GetOrCreateMeasure(int?measureId)
        {
            var measureModel = default(MeasureModel);

            var measure = default(Measure);

            if (measureId.HasValue && measureId.Value > 0)
            {
                using (var session = base.GetSession())
                {
                    measure = session.Get <Measure>(measureId.Value);
                }
            }

            if (measure != null)
            {
                measureModel = new MeasureModel(measure);
            }
            else
            {
                measure      = new Measure();
                measureModel = new MeasureModel(measure);
            }

            return(measureModel);
        }
Esempio n. 2
0
        private UserModel GetUserFromIdentity(ClaimsIdentity identity)
        {
            UserModel _user = new UserModel();

            _user.UserId   = identity.FindFirst("UserId").Value;
            _user.UserName = identity.FindFirst(ClaimTypes.Name).Value;
            _user.Email    = identity.FindFirst(ClaimTypes.Email).Value;

            string strHeight = "0.0";

            if (identity.FindFirst("Height") != null)
            {
                strHeight = identity.FindFirst("Height").Value;
                double d;
                if (double.TryParse(strHeight, out d))
                {
                    _user.Height = d;
                }
            }
            if (identity.FindFirst("Gender") != null)
            {
                _user.Gender = identity.FindFirst("Gender").Value;
            }
            Body         b  = new Body(db, _user);
            MeasureModel me = b.GetMeasurements(_user.UserId);

            _user.Measurements = me;
            return(_user);
        }
Esempio n. 3
0
        public async Task <int> AddMeasureAsync(MeasureModel measureModel)
        {
            measureModel.Date   = DateTime.Now;
            measureModel.Status = "InProcess";

            return(await _measureRepository.AddMeasureAsync(measureModel));
        }
Esempio n. 4
0
        public ActionResult Measure(MeasureModel me)
        {
            if (this.user.Gender == "M")
            {
                if (me.Neck == 0 || me.Abdomen == 0 || me.BodyWeight == 0)
                {
                    TempData["Error"] = "Unable to add measurements - Please ensure all required fields have a value";
                }
            }
            else
            {
                if (me.Neck == 0 || me.Waist == 0 || me.Hips == 0 || me.BodyWeight == 0)
                {
                    TempData["Error"] = "Unable to add measurements - Please ensure all required fields have a value";
                }
            }

            if (TempData["Error"] != null)
            {
                return(RedirectToAction("../Main/Home"));
            }

            try {
                Body b = new Body(this.db, this.user);
                b.AddMeasurements(me);
                this.user.Measurements = me;
                ViewModel model = new ViewModel();
                TempData["Status"] = "Measurements successfully recorded";
            } catch {
                TempData["Error"] = "Unable to add measurements - Please try again later";
            }
            return(RedirectToAction("../Main/Home"));
        }
Esempio n. 5
0
        public int Search(MeasureModel searchCondition, out List <MeasureModel> lstModel, out int total, int _page)
        {
            int returnCode = (int)Common.ReturnCode.Succeed;

            lstModel = new List <MeasureModel>();
            _page    = _page * 15 - 15;
            total    = new int();
            try
            {
                string sql  = "SELECT `id`, `code`, `name`, `description` FROM `product_measure` WHERE TRUE ";
                string _sql = "SELECT COUNT(`id`) FROM product_measure AS i WHERE TRUE ";
                if (!string.IsNullOrEmpty(searchCondition.code))
                {
                    sql  += "AND `code` LIKE @code ";
                    _sql += "AND `code` LIKE @code ";
                }
                if (!string.IsNullOrEmpty(searchCondition.name))
                {
                    sql  += "AND `name` LIKE @name ";
                    _sql += "AND `name` LIKE @name ";
                }
                sql     += " LIMIT @page,15 ";
                lstModel = db.Query <MeasureModel>(sql, new { code = '%' + searchCondition.code + '%', name = '%' + searchCondition.name + '%', page = _page }).ToList();
                total    = db.ExecuteScalar <int>(_sql, new { code = '%' + searchCondition.code + '%', name = '%' + searchCondition.name + '%' });
                return(returnCode);
            }
            catch (Exception ex)
            {
                return(returnCode = (int)Common.ReturnCode.UnSuccess);
            }
        }
Esempio n. 6
0
        public void UpdateSeries(string path, DateTime timestamp, float value)
        {
            long id = GetCounterId(path);

            UpdateDatabase(id, timestamp, value);

            MeasureModel newValue = new MeasureModel(timestamp, Math.Round(value, 2));

            List <Series> listeners;

            if (CounterListeners.TryGetValue(path, out listeners))
            {
                foreach (Series series in listeners)
                {
                    IChartValues values = series.Values;
                    values.Add(newValue);

                    // Update axis limits if chart is visible
                    if (series.DataContext != BindingOperations.DisconnectedSource)
                    {
                        var chartItem = (ChartItem)series.DataContext;
                        chartItem?.SetAxisLimits(timestamp);
                    }

                    if (values.Count > maxPointsPerChart)
                    {
                        values.RemoveAt(0);
                    }
                }
            }
        }
Esempio n. 7
0
        public async Task <MeasureModel> Add(MeasureModel measure)
        {
            measure.Status = MeasureStatus.Pending;
            MeasureModel newMeasureModel = await _measureRepository.Add(measure);

            return(newMeasureModel);
        }
Esempio n. 8
0
        //Check error of model
        private bool isError(MeasureModel Model, int ActionType, out List <string> lstMessage)
        {
            bool isError = false;

            lstMessage = new List <string>();
            if (Model.code.Contains(" "))
            {
                isError = true;
                lstMessage.Add("[Code] must not contains space character!");
            }
            if ((int)Common.ActionType.Add == ActionType)
            {
                string strQuery = "SELECT `id` FROM `product_measure` WHERE `code` = @code LIMIT 1 ";
                var    hasItem  = _db.Query <int>(strQuery, new { code = Model.code }).ToList();
                if (hasItem.Count != 0)
                {
                    isError = true;
                    lstMessage.Add("[Code] is duplicate!");
                }
            }
            if ((int)Common.ActionType.Update == ActionType)
            {
                string strQuery = "SELECT `id` FROM `product_measure` WHERE `code` = @code AND `id` <> @id LIMIT 1";
                var    hasItem  = _db.Query <int>(strQuery, new { code = Model.code, id = Model.id }).ToList();
                if (hasItem.Count != 0)
                {
                    isError = true;
                    lstMessage.Add("[Code] is duplicate!");
                }
            }
            return(isError);
        }
Esempio n. 9
0
        public async Task StartAsync()
        {
            var val = (ChartValues <MeasureModel>) this.SeriesCollection[0].Values;
            await Task.Run(() =>
            {
                while (Break == false)
                {
                    ushort[] b = ModbusCommand.command.Operation(Getter.channel_ch1);
                    var x      = (double)((float)b[0]) / 1000 + 1520; //26 page nm
                    var y      = (double)Utility.GetSingle(0, b[1]);
                    MeasureModel measureModel = new MeasureModel()
                    {
                        ValueX = x, ValueY = y
                    };
                    val.RemoveAt(0);
                    val.Add(measureModel);
                }
                //  s_cts.Cancel();
            });

            Break = false;
            //    await Task.WhenAll(new[] { cancelTask });
            //   ModbusCommand._serialPort.Close();
            //  ModbusCommand._serialPort.Dispose();
        }
Esempio n. 10
0
        public ActionResult Index(MeasureModel Model, int?page)
        {
            var pageNumber = page ?? 1;
            List <MeasureModel> lstModel = new List <MeasureModel>();
            int total = new int();

            if (!string.IsNullOrEmpty(Session["m_code"] as string))
            {
                Model.code = Session["m_code"].ToString();
            }
            if (!string.IsNullOrEmpty(Session["m_name"] as string))
            {
                Model.name = Session["m_name"].ToString();
            }
            _measureBLL.Search(Model, out lstModel, out total, pageNumber);
            var list = new StaticPagedList <MeasureModel>(lstModel, pageNumber, 15, total);

            ViewBag.ListSearch = lstModel.OrderByDescending(x => x.id);
            ViewBag.page       = 0;
            if (page != null)
            {
                ViewBag.page = pageNumber - 1;
            }
            return(View(new Tuple <MeasureModel, IPagedList <MeasureModel> >(Model, list)));
        }
Esempio n. 11
0
        public bool isError(MeasureModel Model, int action, out List <string> lstMessage)
        {
            bool isError = false;

            lstMessage = new List <string>();
            if (Model.code.Contains(" "))
            {
                isError = true;
                lstMessage.Add("[Code] must not contains space character!");
            }
            if ((int)Common.ActionType.Add == action)
            {
                var result = db.Query <MeasureModel>("SELECT * FROM `product_measure` WHERE `code` = @code", new { code = Model.code.Trim() }).ToList();
                if (result.Count != 0)
                {
                    isError = true;
                    lstMessage.Add("[Code] is duplicate!");
                }
            }
            if ((int)Common.ActionType.Update == action)
            {
                var result = db.Query <MeasureModel>("SELECT * FROM `product_measure` WHERE `code` = @code AND `id` <> @id", new { code = Model.code.Trim(), id = Model.id }).ToList();
                if (result.Count != 0)
                {
                    isError = true;
                    lstMessage.Add("[Code] is duplicate!");
                }
            }
            return(isError);
        }
        public async Task StartAsync()
        {
            Graph2.MaxX = 1530;
            Graph2.MinX = 1525;
            Graph2.MinY = 0;
            await Task.Run(() =>
            {
                while (Break == false)
                {
                    ushort[] b = ModbusCommand.command.Operation(Getter.channel_ch1);
                    var x      = (double)((float)b[0]) / 1000 + 1520; //26 page nm
                    var y      = (double)Utility.GetSingle(0, b[1]);
                    MeasureModel measureModel = new MeasureModel()
                    {
                        ValueX = x, ValueY = y
                    };
                    //if (_values.Count > 800)
                    //{
                    //    _values.RemoveAt(0);
                    //}
                    _values.Add(measureModel);
                }
                //  s_cts.Cancel();
            });

            Break = false;
            //    await Task.WhenAll(new[] { cancelTask });
            //   ModbusCommand._serialPort.Close();
            //  ModbusCommand._serialPort.Dispose();
        }
Esempio n. 13
0
        public ActionResult Edit(MeasureModel Model)
        {
            if (string.IsNullOrEmpty(Model.id.ToString()))
            {
                TempData["Error"] = "Data has already been deleted by other user!";
                return(RedirectToAction("Index"));
            }
            List <string> lstMsg     = new List <string>();
            int           returnCode = _measureBLL.Update(Model, out lstMsg);

            if (ModelState.IsValid)
            {
                if (!((int)Common.ReturnCode.Succeed == returnCode))
                {
                    if (lstMsg != null)
                    {
                        for (int i = 0; i < lstMsg.Count(); i++)
                        {
                            ModelState.AddModelError(string.Empty, lstMsg[i]);
                        }
                    }
                    return(View(Model));
                }
                TempData["Success"] = "Updated Successfully!";
                return(RedirectToAction("View", new { @id = Model.id }));
            }
            return(View());
        }
Esempio n. 14
0
        public void AddMeasurements(MeasureModel me)
        {
            var        strUserId = user.UserId;
            var        strId     = Guid.NewGuid().ToString();
            SqlCommand cmd       = new SqlCommand(@"insert into measurement(id, neck, shoulder, arm, forearm, wrist, chest, waist, abdomen, hips, thigh, knee, calf, bodyweight, userid)
values(@id, @neck, @shoulder, @arm, @forearm, @wrist, @chest, @waist, @abdomen, @hips, @thigh, @knee, @calf, @weight, @userid)");

            cmd.Parameters.AddWithValue("@id", strId);
            cmd.Parameters.AddWithValue("@neck", cm.AddParameter(me.Neck));
            cmd.Parameters.AddWithValue("@shoulder", cm.AddParameter(me.Shoulder));
            cmd.Parameters.AddWithValue("@arm", cm.AddParameter(me.Arm));
            cmd.Parameters.AddWithValue("@forearm", cm.AddParameter(me.Forearm));
            cmd.Parameters.AddWithValue("@wrist", cm.AddParameter(me.Wrist));
            cmd.Parameters.AddWithValue("@chest", cm.AddParameter(me.Chest));
            cmd.Parameters.AddWithValue("@waist", cm.AddParameter(me.Waist));
            cmd.Parameters.AddWithValue("@abdomen", cm.AddParameter(me.Abdomen));
            cmd.Parameters.AddWithValue("@hips", cm.AddParameter(me.Hips));
            cmd.Parameters.AddWithValue("@thigh", cm.AddParameter(me.Thigh));
            cmd.Parameters.AddWithValue("@knee", cm.AddParameter(me.Knee));
            cmd.Parameters.AddWithValue("@calf", cm.AddParameter(me.Calf));
            cmd.Parameters.AddWithValue("@weight", cm.AddParameter(me.BodyWeight));
            cmd.Parameters.AddWithValue("@userid", strUserId);
            db.ExecNonQuery(cmd);

            cmd = new SqlCommand(@"insert into bodyweight(userid, bodyweight, measurementid) values(@userid, @weight, @measurementid)");
            cmd.Parameters.AddWithValue("@userid", strUserId);
            cmd.Parameters.AddWithValue("@weight", cm.AddParameter(me.BodyWeight));
            cmd.Parameters.AddWithValue("@measurementid", strId);
            db.ExecNonQuery(cmd);
        }
Esempio n. 15
0
        public async Task<ActionResult> Update(MeasureModel model, int dmsId)
        {
            if (ModelState.IsValid)
            {
                //if (model.Dms.Id < 1)
                //    return Content("Department is required!");

                if (model.MeasureType.Id < 1)
                    return Content("Progress is required!");

                var measure = await _measureService.GetByIdAsync(model.Id);
                if (measure == null)
                    return Content("No measure found with the specified id");

                //if Dms has changed
                /*if (measure.DmsId != model.Dms.Id)
                {
                    var existMeasure = _measureService.GetMeasureByCode(model.MeasureCode, dmsId);
                    if (existMeasure.Result != null)
                        return Content("Measure with DMS and MeasureCode like this has Existed!");

                    measure.MeasureCode = model.MeasureCode;
                    measure.MeasureName = model.MeasureName;
                    measure.DmsId = model.Dms.Id;
                    measure.MeasureType = (MeasureType)model.MeasureType.Id;
                    measure.Target = model.Target;
                    measure.Note = model.Note ?? "";
                    measure.Unit = model.Unit;
                    measure.UpdatedDate = DateTime.Now;
                    measure.Active = model.Active;

                    await _measureService.UpdateMeasureOwner(measure, model.ListUsername);
                    return Json(new { status = "success" });
                }*/

                if (model.MeasureCode != measure.MeasureCode)
                {
                    var existedMeasure = await _measureService.GetMeasureByMeasureCodeAndDmsId(model.MeasureCode, model.Dms.Id);
                    if(existedMeasure == null)
                        measure.MeasureCode = model.MeasureCode;
                    else
                        return Content("MeasureCode has Existed in this Dms");
                }
                measure.MeasureName = model.MeasureName;
                measure.MeasureType = (MeasureType)model.MeasureType.Id;
                measure.Target = model.Target;
                measure.Note = model.Note;
                measure.Unit = model.Unit;
                measure.UpdatedDate = DateTime.Now;
                measure.Active = model.Active;
                measure.Order = model.Order;

                await _measureService.UpdateMeasureOwner(measure, model.ListUsername);
                return Json(new { status = "success" });
            }

            return Content("Can not update Measure because model state is invalid");
        }
        public async Task <int> CreateAsync(MeasureModel measureModel)
        {
            Entities.Measure measure = _mapper.Map <Entities.Measure>(measureModel);
            var e = await _measureContext.Measures.AddAsync(measure);

            await _measureContext.SaveChangesAsync();

            return(e.Entity.id);
        }
        public async Task <MeasureModel> Add(MeasureModel measureModel)
        {
            Measure measure = _mapper.Map <Measure>(measureModel);

            _measureDbContext.Measures.Add(measure);
            await _measureDbContext.SaveChangesAsync();

            return(_mapper.Map <MeasureModel>(measure));
        }
Esempio n. 18
0
 public void InsertData(MeasureModel mm)
 {
     data.Add(mm.Value);
     if (data.Count > data_size)
     {
         data.RemoveAt(0);
     }
     updatetime = mm.DateTime;
 }
Esempio n. 19
0
        private FatModel GetBodyFat(MeasureModel me, double height, double weight)
        {
            FatModel fat = new FatModel();

            fat.BodyFat  = this.CalculateBodyFat(me, height);
            fat.FatMass  = weight * fat.BodyFat;
            fat.LeanMass = weight - fat.FatMass;
            return(fat);
        }
Esempio n. 20
0
        private void Read3()
        {
            // double x = 1528.5;
            // double y = 6.55733501913825e-46;
            float x;
            float y;
            List <(ushort x, ushort y)> ulist  = new List <(ushort x, ushort y)>();
            List <(float x, float y)>   fllist = new List <(float x, float y)>();
            var list = ChartValues.ToList();

            while (IsReading)
            {
                Thread.Sleep(500);
                ushort[] b = ModbusCommand.command.Operation(Getter.channel_spectral_ch1);
                ulist.Add((b[0], b[1]));
                x = ((float)b[0]) / 1000 + 1520;
                y = Utility.GetSingle(0, b[1]);

                fllist.Add((x, y));
                MeasureModel m = new MeasureModel
                {
                    ValueX = (double)x,
                    ValueY = (double)y
                };
                list.Add(m);
                try
                {
                    list = list.OrderBy(t => t.ValueX).ToList();
                    ChartValues.Clear();
                    ChartValues.AddRange(list);
                }
                catch (Exception e)
                {
                    var t = e;
                }
                //   ChartValues = v1;
                //ChartValues.Add(new MeasureModel
                //{
                //    ValueX = x,
                //    ValueY = y

                //    //     DateTime = now,
                //    //    Value = _trend
                //});
                // SetAxisLimits(now);
                //  if (ChartValues.Count > 100) ChartValues.RemoveAt(0);
            }


            //var x1 = fllist.Select(b => b.x);
            //var y1 = fllist.Select(b => b.y);
            //float maxx = x1.Max();
            //float minx = x1.Min();
            //float maxy = y1.Max();
            //float miny = y1.Min();
        }
Esempio n. 21
0
 public ActionResult Edit(MeasureModel model)
 {
     if (ModelState.IsValid)
     {
         db.Entry(model).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details/" + model.MeasureId.ToString()));
     }
     return(View(model));
 }
Esempio n. 22
0
        public void InsertMeasureModel(DateTime date_time, Double value)
        {
            connecter.InsertData(date_time, value);
            MeasureModel mm = new MeasureModel();

            mm.DateTime = date_time;
            mm.Value    = value;
            measureModels.Add(mm);
            graymodel.InsertData(mm);
        }
Esempio n. 23
0
        public Task WriteMeasuresToDb()
        {
            _logger.Log(LogLevel.Information, "STARTING HANGFIRE BACKGROUND JOB....");

            MeasureModel measure = _sensorsProcessor.GetData();

            CheckSensorsResponseSuccess();
            _repository.InsertMeasure(measure);
            _repository.Save();
            return(Task.Delay(10));
        }
Esempio n. 24
0
        /// <summary>
        /// Receiving data for graph
        /// </summary>
        public static async Task <ChartValues <MeasureModel> > FetchAsync(int?id = null)
        {
            var Values = new ChartValues <MeasureModel>();

            try
            {
                using (SQLiteConnection conn = new SQLiteConnection("Data Source = Interrogator.db; Version = 3; New = True; Compress = True;"))
                {
                    string query = "SELECT id, coordinatey, coordinatex FROM chartdata" + (id != null ? $" where id >  {id}" : "");
                    using (SQLiteCommand command = new SQLiteCommand(query, conn))
                    {
                        await conn.OpenAsync();

                        using (var reader = await command.ExecuteReaderAsync())
                        {
                            while (await reader.ReadAsync())
                            {
                                //  var y0 = (double)reader["coordinatey"];
                                //var y1 = (double)reader["coordinatex"];
                                var model = new MeasureModel()
                                {
                                    ValueY = (double)reader["coordinatey"], ValueX = (double)reader["coordinatex"]
                                };
                                Values.Add(model);
                                if (lastId < (Int64)reader["id"])
                                {
                                    lastId = (Int64)reader["id"];
                                }
                            }
                        }
                    }
                }
                return(Values);
            }
            catch (SQLiteException ex)
            {
                throw new SQLiteException(ex.Message);
                // MessageBox.Show(ex.Message);
            }

            catch (Exception ex)
            {
                throw new SQLiteException(ex.Message);
                // MessageBox.Show(ex.Message);
            }
            finally
            {
                //return Values;

                // return Values;
            }
            // return null;
        }
Esempio n. 25
0
        // GET: /Measure/Details/5
        public ActionResult Details(int?id, string ReturnUrl)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MeasureModel model = new MeasureModel();

            model.measure = (from measure in db.Measures
                             .Include(ma => ma.Materials.Select(r => r.Rooms))
                             .Include(ma => ma.Materials.Select(mt => mt.MaterialType))
                             .Include(s => s.Store)
                             where measure.Id == id.Value
                             select measure).FirstOrDefault();
            if (model.measure == null)
            {
                return(HttpNotFound());
            }
            model.customer = db.Customers.Find(model.measure.CustomerId);
            if (model.customer == null)
            {
                return(HttpNotFound());
            }
            model.CustomerId = model.customer.Id;
            model.MeasureId  = model.measure.Id;

            model.Rooms = new List <RoomModel>();
            foreach (Room r in db.Rooms.OrderBy(r => r.Name))
            {
                RoomModel room = new RoomModel();
                room.RoomId     = r.Id;
                room.Name       = r.Name;
                room.ShowCloset = r.ShowCloset;
                foreach (MeasureMaterial mm in model.measure.Materials)
                {
                    MeasureRoom mr = mm.Rooms.FirstOrDefault(mr2 => mr2.RoomId == r.Id);
                    if (mr != null)
                    {
//						room.Name = mr.Name;
                        room.MaterialId    = mr.MaterialId;
                        room.IncludeCloset = mr.IncludeCloset;
                        break;
                    }
                }

                model.Rooms.Add(room);
            }
            ViewBag.ReturnUrl   = ReturnUrl;
            ViewBag.ShowDeleted = true;

            ViewBag.MaterialList = InsertEmptyFirst(new SelectList(model.measure.Materials, "Id", "Description", null));
            return(View(model));
        }
    public MeasureModel GetNext()
    {
        var model = new MeasureModel {
            DateTime = DateTime.Now, Value = current
        };

        current -= step;
        if (current < 0 || max < current)
        {
            step    = -step;
            current = current < 0 ? 0 : max;
        }
        return(model);
    }
        public async Task Post(MeasureDTO measure)
        {
            MeasureModel measureModel = _mapper.Map <MeasureModel>(measure);

            measureModel.Status = MeasureStatus.Pending;
            MeasureModel newMeasureModel = await _measureService.Add(measureModel);

            await _messageSession.Publish <IMeasureAdded>(message =>
            {
                message.MeasureId  = newMeasureModel.Id;
                message.Weight     = measure.Weight;
                message.UserFileId = measure.UserFileId;
            });
        }
Esempio n. 28
0
        public async Task <IActionResult> Create([FromBody] MeasureModel model)
        {
            var entity = mapper.Map <Measure>(model);

            this.ctx.Add(entity);
            if (await this.ctx.SaveChangesAsync() > 0)
            {
                model.Id = entity.Id;
                var url = Url.Link("MeasureGet", new { id = model.Id });
                return(Created(url, model));
            }

            return(BadRequest());
        }
Esempio n. 29
0
        public async Task <int> AddMeasureAsync(MeasureModel measureModel)
        {
            MeasureEntity measureEntity = _mapper.Map <MeasureEntity>(measureModel);
            await _measureContext.Measures.AddAsync(measureEntity);

            await _measureContext.SaveChangesAsync();

            MeasureEntity measure = await _measureContext.Measures
                                    .FirstOrDefaultAsync(m => m.CardId == measureEntity.CardId &&
                                                         m.Date == measureEntity.Date &&
                                                         m.Status == measureEntity.Status &&
                                                         m.Weight == measureEntity.Weight);

            return(measure.Id);
        }
Esempio n. 30
0
        public ActionResult IndexPost(MeasureModel Model, int?page)
        {
            var pageNumber = page ?? 1;
            List <MeasureModel> lstModel = new List <MeasureModel>();
            int total = new int();

            _measureBLL.Search(Model, out lstModel, out total, pageNumber);
            var list = new StaticPagedList <MeasureModel>(lstModel, pageNumber, 15, total);

            ViewBag.ListSearch      = lstModel.OrderByDescending(x => x.id);
            Session["m_code"]       = Model.code;
            Session["m_name"]       = Model.name;
            TempData["CountResult"] = total.ToString() + " row(s) found!";
            return(View(new Tuple <MeasureModel, IPagedList <MeasureModel> >(Model, list)));
        }