public void filterRecord(int length, string property, string value, string value2, ref DentalMenu[] dentalMenu)
 {
     /* Fields that can be filter
      * Name
      * Desription
      * Status
      */
     //Filter for a specific patient
     int fetch;
     dentalMenu = null;
     if (property.Equals("Name"))
     {
         value = value.ToLower();
         var records = db.DentalMenus.Where(dm => dm.Name.ToLower().Contains(value) || dm.Name.ToLower().ToLower().Equals(value)).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDentalMenu = db.DentalMenus.Where(dm => dm.Name.ToLower().Contains(value) || dm.Name.ToLower().ToLower().Equals(value))
                 .OrderBy(dm => dm.Id).Skip((length)).Take(fetch).ToArray();
             dentalMenu = getDentalMenu;
         }
     }
     else if (property.Equals("Description"))
     {
         value = value.ToLower();
         var records = db.DentalMenus.Where(dm => dm.Description.ToLower().Contains(value) || dm.Description.ToLower().ToLower().Equals(value)).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDentalMenu = db.DentalMenus.Where(dm => dm.Description.ToLower().Contains(value) || dm.Description.ToLower().ToLower().Equals(value))
                 .OrderBy(dm => dm.Id).Skip((length)).Take(fetch).ToArray();
             dentalMenu = getDentalMenu;
         }
     }
     else if (property.Equals("Url"))
     {
         value = value.ToLower();
         var records = db.DentalMenus.Where(dm => dm.Url.ToLower().Contains(value) || dm.Url.ToLower().ToLower().Equals(value)).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDentalMenu = db.DentalMenus.Where(dm => dm.Url.ToLower().Contains(value) || dm.Url.ToLower().ToLower().Equals(value))
                 .OrderBy(dm => dm.Id).Skip((length)).Take(fetch).ToArray();
             dentalMenu = getDentalMenu;
         }
     }
     else if (property.Equals("ParentName"))
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Integer");
         var records = db.DentalMenus.Where(dm => dm.ParentId == strManipulate.intValue).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDentalMenu = db.DentalMenus.Where(dm => dm.ParentId == strManipulate.intValue)
                 .OrderBy(cs => cs.Id).Skip((length)).Take(fetch).ToArray();
             dentalMenu = getDentalMenu;
         }
     }
     //status
     else
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Integer");
         var records = db.DentalMenus.Where(dm => dm.Status == strManipulate.intValue).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDentalMenu = db.DentalMenus.Where(dm => dm.Status == strManipulate.intValue)
                 .OrderBy(dm => dm.Id).Skip((length)).Take(fetch).ToArray();
             dentalMenu = getDentalMenu;
         }
     }
 }
        public IHttpActionResult PutDentalMenu(int id, DentalMenu dentalMenu)
        {
            response.status = "FAILURE";
            if (!ModelState.IsValid || id != dentalMenu.Id)
            {
                response.message = "Bad request.";
                return Ok(response);
            }

            db.Entry(dentalMenu).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
                response.status = "SUCCESS";
                response.objParam1 = dentalMenu;
            }
            catch (Exception e)
            {
                if (!DentalMenuExists(id))
                {
                    response.message = "Menu doesn't exist.";
                }
                else
                {
                    response.message = e.InnerException.InnerException.Message.ToString();
                }
            }

            return Ok(response);
        }
 //Filtering for active menu
 public IHttpActionResult GetDentalMenu(int length, int status, string property, string value, string value2)
 {
     DentalMenu[] dentalMenu = new DentalMenu[pageSize];
     this.filterRecord(length, status, property, value, value2, ref dentalMenu);
     if (dentalMenu != null)
         return Ok(dentalMenu);
     else
         return Ok();
 }
        public IHttpActionResult PostDentalMenu(DentalMenu dentalMenu)
        {
            response.status = "FAILURE";
            if (!ModelState.IsValid)
            {
                response.message = "Bad request.";
                return Ok(response);
            }
            try
            {
                db.DentalMenus.Add(dentalMenu);
                db.SaveChanges();
                response.status = "SUCCESS";
                response.objParam1 = dentalMenu;
            }
            catch (Exception e) {
                response.message = e.InnerException.InnerException.Message.ToString();
            }

            return Ok(response);
        }
 public void filterRecord(int length, int status, string property, string value, string value2, ref DentalMenu[] dentalMenu)
 {
     /* Fields that can be filter
      * Name
      * Desription
      * Status
      */
     //Filter for a specific patient
     int fetch;
     dentalMenu = null;
     if (property.Equals("Name"))
     {
         value = value.ToLower();
         var records = db.DentalMenus.Where(dm => (dm.Name.ToLower().Contains(value) || dm.Name.ToLower().ToLower().Equals(value))
                                                   && dm.Status == status).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDentalMenu = db.DentalMenus.Where(dm => (dm.Name.ToLower().Contains(value) || dm.Name.ToLower().ToLower().Equals(value))
                                                      && dm.Status == status).OrderBy(dm => dm.Id).Skip((length)).Take(fetch).ToArray();
             dentalMenu = getDentalMenu;
         }
     }
     //Description
     else
     {
         value = value.ToLower();
         var records = db.DentalMenus.Where(dm => (dm.Description.ToLower().Contains(value) || dm.Description.ToLower().ToLower().Equals(value))
                                            && dm.Status == status).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getDentalMenu = db.DentalMenus.Where(dm => (dm.Description.ToLower().Contains(value) || dm.Description.ToLower().ToLower().Equals(value))
                                                      && dm.Status == status).OrderBy(dm => dm.Id).Skip((length)).Take(fetch).ToArray();
             dentalMenu = getDentalMenu;
         }
     }
 }