public bool AddPayeeRelation(PayeeRelationType Relation) { try { dbContext.PayeeRelationType.Add(Relation); dbContext.SaveChanges(); return(true); } catch (Exception ex) { logger.LogDebug(ex.Message); } return(false); }
public bool ModifyPayeeRelation(PayeeRelationType modifyRelation) { try { PayeeRelationType relation = dbContext.PayeeRelationType.Single(x => x.Id == modifyRelation.Id); dbContext.Entry(relation).CurrentValues.SetValues(modifyRelation); dbContext.SaveChanges(); return(true); } catch (Exception ex) { logger.LogDebug(ex.Message); } return(false); }
public MessageModel <EditRelationDTO> AddRelation(AddPayeeRelationTypeRequest request) { PayeeRelationType payeeRelationType = new PayeeRelationType { Type = request.Type, Description = request.Description, }; bool result = payeeRelationService.AddPayeeRelation(payeeRelationType); EditRelationDTO relationDTO = mapper.Map <EditRelationDTO>(payeeRelationType); return(new MessageModel <EditRelationDTO> { Success = result, Msg = result ? "" : "Add Fail", Data = relationDTO }); }
public MessageModel <EditRelationDTO> ModifyRelation([FromRoute, SwaggerParameter("id,可從/relation取得", Required = true)] int id, [FromBody] ModifyPayeeRelationTypeRequest request) { PayeeRelationType payeeRelationType = new PayeeRelationType { Id = id, Type = request.Type, Description = request.Description, }; bool result = payeeRelationService.ModifyPayeeRelation(payeeRelationType); EditRelationDTO relationDTO = mapper.Map <EditRelationDTO>(payeeRelationType); return(new MessageModel <EditRelationDTO> { Success = result, Msg = result ? "" : "Modify Fail", Data = relationDTO }); }
public bool DeletePayeeRelation(long id) { try { PayeeRelationType relation = dbContext.PayeeRelationType.Single(x => x.Id == id); if (relation != null) { dbContext.PayeeRelationType.Remove(relation); dbContext.SaveChanges(); return(true); } } catch (Exception ex) { logger.LogDebug(ex.Message); } return(false); }