public HttpResponseMessage DeleteCard([FromBody] RequestDeleteCard request) { if (IsBodyNull(request)) { return(ResponseFail(Constants.BODY_NOT_FOUND)); } if (!CheckCode.checkcode(request.blockCode)) { return(ResponseFail(Constants.CODEERROR)); } try { SmartCard card; using (DB db = new DB(request.blockCode)) { card = db.SmartCards.Find(request.ID); db.SmartCards.Remove(card); db.SaveChanges(); } var model = new CardViewModel(); string info = "Xóa thẻ : " + request.ID + "\n -STT : " + card.Identify + "\n -Mã thẻ : " + request.ID + "\n -Loại thẻ : " + model.GetPartName(card.ID, request.blockCode) + "\n -Sử dụng : " + card.Using; var logModel = new LogViewModel(); logModel.AddLog(ActionType.DELETE_CARD_INFO, DateTime.Now, info, request.blockCode); return(ResponseSuccess(Constants.SUCCESS, model.Statistical(request.blockCode))); } catch { return(ResponseSuccess(Constants.FAILD)); } }