/// <summary>
        /// Edit existing audit reason
        /// </summary>
        /// <param name="id">id</param>
        /// <returns></returns>
        public ActionResult AuditReasonEdit(int id)
        {
            MODEL.AuditReason auditReason = null;
            try
            {
                AuditReasonService auditReasonService = new AuditReasonService();

                //Get audit reason details
                AuditReasonVO auditReasonVO = auditReasonService.GetAuditReasonById(id);

                if (auditReasonVO == null)
                {
                    ModelState.AddModelError("", String.Format(Constants.ITEM_NOT_FOUND, Constants.AUDIT_REASON));
                }
                else
                {
                    auditReason = new AuditReason(auditReasonVO);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }
            return(PartialView("AuditReasonDetails", auditReason));
        }
        /// <summary>
        ///  Returns list of audit Reasons
        /// </summary>
        /// <param name="param">The filter an other parameters</param>
        /// <returns>List of audit reasons</returns>
        // GET: /Administration/AuditReasonList
        public ActionResult AuditReasonList(MODEL.jQueryDataTableParamModel param)
        {
            try
            {
                AuditReasonService       auditReasonService = new AuditReasonService();
                List <MODEL.AuditReason> auditReasonList    = new List <AuditReason>();


                //Get the list of Audit Reasons VO's
                List <AuditReasonVO> auditReasonVOList = auditReasonService.GetAuditReasonCodeVOList();

                foreach (var auditReasonVO in auditReasonVOList)
                {
                    MODEL.AuditReason auditReason = new MODEL.AuditReason(auditReasonVO);
                    auditReasonList.Add(auditReason);
                }


                //get the field on with sorting needs to happen and set the
                //ordering function/delegate accordingly.
                int sortColumnIndex  = Convert.ToInt32(Request["iSortCol_0"]);
                var orderingFunction = GetAuditReasonOrderingFunction(sortColumnIndex);

                var result = GetFilteredObjectsOrderByAscending(param, auditReasonList, orderingFunction);
                return(result);
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
        public ActionResult AuditReasonSave(MODEL.AuditReason model)
        {
            try
            {
                bool ismodelValid = ModelState.IsValid;
                if (ismodelValid)
                {
                    //Get user id
                    int?userId = Session.GetUserId();
                    AuditReasonService auditReasonService = new AuditReasonService();
                    //AuditReasonVO auditReasonVO = new AuditReasonVO(model, userId);

                    AuditReasonVO auditReasonVO = model.Transpose(userId);

                    auditReasonService.SaveAuditReason(auditReasonVO);
                    return(new HttpStatusCodeResult(200));
                }
                else
                {
                    throw new ApplicationException(String.Format(Constants.CANNOT_SAVE, Constants.AUDIT_REASON));
                }
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
 /// <summary>
 /// Create new audit reason
 /// </summary>
 /// <returns></returns>
 // GET: /Administration/AuditReasonCreate
 public ActionResult AuditReasonCreate()
 {
     try
     {
         MODEL.AuditReason auditReason = new MODEL.AuditReason();
         return(PartialView("AuditReasonDetails", auditReason));
     }
     catch (Exception e)
     {
         return(new HttpStatusCodeAndErrorResult(500, e.Message));
     }
 }