public async Task <SiteTransplantTotal> SaveSiteTransplantTotalAsync(TransplantCellType cellType, ClinicalPopulationType popType, TransplantType transplantType, Guid?id, int siteId, bool isHaploid, int numberOfUnits, DateTime startDate, DateTime endDate, string savedBy) { SiteTransplantTotal row = null; if (id.HasValue) { row = this.GetById(id.Value); if (row == null || row.SiteId != siteId) { throw new Exception("Cannot find total"); } row.TransplantCellTypeId = cellType.Id; row.ClinicalPopulationTypeId = popType.Id; row.TransplantTypeId = transplantType.Id; row.IsHaploid = isHaploid; row.NumberOfUnits = numberOfUnits; row.StartDate = startDate; row.EndDate = endDate; row.UpdatedBy = savedBy; row.UpdatedDate = DateTime.Now; await base.SaveAsync(row); } else { row = new SiteTransplantTotal { Id = Guid.NewGuid(), SiteId = siteId, TransplantCellTypeId = cellType.Id, ClinicalPopulationTypeId = popType.Id, TransplantTypeId = transplantType.Id, IsHaploid = isHaploid, NumberOfUnits = numberOfUnits, StartDate = startDate, EndDate = endDate, CreatedDate = DateTime.Now, CreatedBy = savedBy }; await base.Repository.AddAsync(row); } return(row); }
public SiteCollectionTotal SaveSiteCollectionTotal(CollectionType collectionType, ClinicalPopulationType popType, Guid?id, int siteId, int numberOfUnits, DateTime startDate, DateTime endDate, string savedBy) { SiteCollectionTotal row = null; if (id.HasValue) { row = this.GetById(id.Value); if (row == null || row.SiteId != siteId) { throw new Exception("Cannot find total"); } row.CollectionTypeId = collectionType.Id; row.ClinicalPopulationTypeId = popType.Id; row.NumberOfUnits = numberOfUnits; row.StartDate = startDate; row.EndDate = endDate; row.UpdatedBy = savedBy; row.UpdatedDate = DateTime.Now; base.Save(row); } else { row = new SiteCollectionTotal { Id = Guid.NewGuid(), SiteId = siteId, CollectionTypeId = collectionType.Id, ClinicalPopulationTypeId = popType.Id, NumberOfUnits = numberOfUnits, StartDate = startDate, EndDate = endDate, CreatedDate = DateTime.Now, CreatedBy = savedBy }; base.Repository.Add(row); } return(row); }