public CategoryFindResponse Find(int id) { try { var response = new CategoryFindResponse(); var bc = new CategoryBusiness(); response.Result = bc.Find(id); return(response); } catch (Exception ex) { var httpError = new HttpResponseMessage { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public JsonResult Delete(string stkns) { string JsonStr = ""; bool isSuccess = true; string message = "Delete Successful!"; _unitOfWork.BeginTransaction(); try { foreach (string tokenkey in stkns.Substring(1).Split('~')) { List <Category> categoryList = _categoryBusiness.GetListWT(x => x.TokenKey == tokenkey).ToList(); foreach (Category cat in categoryList) { int deleteId = Convert.ToInt32(cat.CategoryId); var br = _categoryBusiness.Find(deleteId); _categoryBusiness.Delete(br); _unitOfWork.SaveChanges(); } } _unitOfWork.Commit(); } catch (Exception ex) { _unitOfWork.Rollback(); message = "Delete Unsuccessful!"; throw ex; } finally { _unitOfWork.Dispose(); } TempData["Success"] = message; TempData["isSuccess"] = isSuccess.ToString(); JsonStr = "{\"message\":\"" + message + "\",\"isSuccess\":\"" + isSuccess + "\"}"; return(Json(JsonStr, JsonRequestBehavior.AllowGet)); }
public FindResponse <Category> Find(int id) { logger.Info($"Inicio de la busqueda de la categoria con id {id}"); try { var response = new FindResponse <Category>(); var bc = new CategoryBusiness(); response.Result = bc.Find(id); return(response); } catch (Exception ex) { logger.Error($"Error al obtener la categoria {id}", ex); var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }