public dynamic GetCompanies(String shares_Type, String beneficiary, String shareholderID) { List <StockAccount> stockAccount; List <StockAccountDto> stockAccountDtos = new List <StockAccountDto>(); if (shares_Type != null && beneficiary == null && shareholderID == null) { stockAccount = stocky.StockAccount.Where(e => e.ShareTypeId == shares_Type).ToList(); } else if (shares_Type == null && beneficiary != null && shareholderID == null) { stockAccount = stocky.StockAccount.Where(e => e.Beneficiary == beneficiary).ToList(); } else if (shares_Type == null && beneficiary == null && shareholderID != null) { stockAccount = stocky.StockAccount.Where(e => e.ShareholderId == shareholderID).ToList(); } else if (shares_Type != null && beneficiary != null && shareholderID == null) { stockAccount = stocky.StockAccount.Where(e => e.ShareTypeId == shares_Type && e.Beneficiary == beneficiary).ToList(); } else if (shares_Type != null && beneficiary == null && shareholderID != null) { stockAccount = stocky.StockAccount.Where(e => e.ShareTypeId == shares_Type && e.ShareholderId == shareholderID).ToList(); } else if (shares_Type == null && beneficiary != null && shareholderID != null) { stockAccount = stocky.StockAccount.Where(e => e.Beneficiary == beneficiary && e.ShareholderId == shareholderID).ToList(); } else if (shares_Type == null && beneficiary == null && shareholderID == null) { stockAccount = stocky.StockAccount.ToList(); } else { stockAccount = stocky.StockAccount.Where(e => e.Beneficiary == beneficiary && e.ShareholderId == shareholderID && e.ShareTypeId == shares_Type).ToList(); } foreach (StockAccount com in stockAccount) { StockAccountDto dto = new StockAccountDto( com.Id, com.Status, com.SharesType, com.CurrentAmount, com.Beneficiary, com.ExpiredDate, com.ShareholderId, com.ShareTypeId); stockAccountDtos.Add(dto); } return(stockAccountDtos); }
public void PostCompany([FromBody] StockAccountDto stockAccountDto) { StockAccount com = new StockAccount(); com.Id = stockAccountDto.Id; com.Status = stockAccountDto.Status; com.SharesType = stockAccountDto.SharesType; com.CurrentAmount = stockAccountDto.CurrentAmount; com.Beneficiary = stockAccountDto.Beneficiary; com.ExpiredDate = stockAccountDto.ExpiredDate; com.ShareholderId = stockAccountDto.ShareholderId; com.ShareTypeId = stockAccountDto.ShareTypeId; stocky.StockAccount.Add(com); stocky.SaveChanges(); }
public void PutStockAccount(String id, [FromBody] StockAccountDto stockAccountDto) { // stocky.Company.Update(id, com); StockAccount com = stocky.StockAccount.Where(e => e.Id == stockAccountDto.Id).Single <StockAccount>(); com.Id = stockAccountDto.Id; com.Status = stockAccountDto.Status; com.SharesType = stockAccountDto.SharesType; com.CurrentAmount = stockAccountDto.CurrentAmount; com.Beneficiary = stockAccountDto.Beneficiary; com.ExpiredDate = stockAccountDto.ExpiredDate; com.ShareholderId = stockAccountDto.ShareholderId; com.ShareTypeId = stockAccountDto.ShareTypeId; stocky.Entry(com).State = Microsoft.EntityFrameworkCore.EntityState.Modified; stocky.SaveChanges(); }