public void DeleteDocument(CommissionDocument document) { try { CheckDeleteRight(); Context.CommissionTransactions.Delete(document.Id); var dleteCardIds = Context.CardsTrancport .All() .Where(x => x.CommissionTransaction.Id == document.Id) .Select(x => x.Id).ToArray(); Context.CardsTrancport .DeleteRange(dleteCardIds); Context.SaveChanges(); } catch (AccessDeniedException) { throw; } catch (Exception ex) { Logger.Instance.Log(ex); throw new Exception("Неудалось удалить документ"); } }
public void SaveDocument(CommissionDocument document) { try { CheckAddRight(); var commission = TinyMapper.Map <CommissionTransaction>(document); if (commission.Id == 0) { commission.UserId = User.Id; } Context.CommissionTransactions.AddOrUpdate(commission); Context.SaveChanges(); document.Id = commission.Id; //document.Number = Context.CommissionTransactions.Get(commission.Id).Number; } catch (AccessDeniedException) { throw; } catch (Exception ex) { Logger.Instance.Log(ex); throw new Exception("Неудалось сохранить документ"); } }
public Response DeleteCommission(CommissionDocument document) { try { _WriteLineConsole($"delete commission identity: {document.Identity}"); using (var helper = new CommissionHelper()) { helper.DeleteCommission(document); } return(new Response() { Message = "Документ удален" }); } catch (Exception ex) { _WriteLineError($"delete commission identity: {document?.Identity}", ex.Message); return(new Response(ex)); } }
public SaveEntityResult SaveCommission(CommissionDocument document) { try { _WriteLineConsole($"save commission identity: {document.Identity}"); using (var helper = new CommissionHelper()) helper.SaveCommision(document); return(new SaveEntityResult() { Message = "Данные успешно сохраненны", Id = document.Id, Number = document.Number }); } catch (Exception ex) { _WriteLineError($"save commission identity: {document?.Identity}", ex.Message); return(new SaveEntityResult() { Error = true, Message = ex.Message }); } }
public void SaveCommision(CommissionDocument document) { _logic.SaveDocument(document); }
public void DeleteCommission(CommissionDocument document) { _logic.DeleteDocument(document); }