public ActionResult Edit(int id, ProviderEvidenceDocViewModel collection, string selectedTags)
 {
     try
     {
         if (id > 0)
         {
             if (ModelState.IsValid)
             {
                 var model = _mapper.Map <ProviderEvidenceDoc>(collection);
                 _providerEvidenceDocService.Update(model);
                 return(RedirectToAction("Index", new { providerId = collection.ProviderId, businessId = collection.BusinessId }));
             }
             ModelState.AddModelError(string.Empty, GeneralMessages.DefectiveEntry);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.EmptyId);
         }
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
         }
     }
     return(View(collection));
 }
        public ActionResult Index(ProviderEvidenceDocViewModel collection)
        {
            var request = new FilteredModel <User>
            {
                PageIndex = collection.ThisPageIndex,
                Order     = collection.PageOrder,
                OrderBy   = collection.PageOrderBy
            };
            var offset = (request.PageIndex - 1) * request.PageSize;
            var result = _mapper.Map <IList <ProviderEvidenceDocViewModel> >(_providerEvidenceDocService.GetPaging(_mapper.Map <ProviderEvidenceDoc>(collection), out long totalCount, request.OrderBy, request.Order, offset, request.PageSize));

            if (!result.Any() && totalCount > 0 && request.PageIndex > 1)
            {
                request.PageIndex = (int)(totalCount / request.PageSize);
                if (totalCount % request.PageSize > 0)
                {
                    request.PageIndex++;
                }
                result =
                    _mapper.Map <IList <ProviderEvidenceDocViewModel> >(_providerEvidenceDocService.GetPaging(_mapper.Map <ProviderEvidenceDoc>(collection), out totalCount, request.OrderBy, request.Order, offset, request.PageSize));
            }
            ViewBag.OnePageOfEntries = new StaticPagedList <ProviderEvidenceDocViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount);
            ViewBag.SearchModel      = collection;
            ViewBag.ProviderId       = collection.ProviderId;
            ViewBag.BusinessId       = collection.BusinessId;
            return(View());
        }
 public ActionResult Details(int id, ProviderEvidenceDocViewModel collection)
 {
     try
     {
         if (id > 0)
         {
             _providerEvidenceDocService.Delete(_mapper.Map <ProviderEvidenceDoc>(collection));
             return(RedirectToAction("Index", new { providerId = collection.ProviderId, businessId = collection.BusinessId }));
         }
         ModelState.AddModelError(string.Empty, GeneralMessages.EmptyId);
         return(View(collection));
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
         }
         return(View(collection));
     }
 }