public ActionResult AssociateUnitToDepot(string drugUnitId, int?depotId, int page = 1) { if (drugUnitId != null) { DrugUnitDTO unitToUpdate = drugUnits.GetById(drugUnitId); if (depotId == null) { unitToUpdate.Depot = null; } else { if (unitToUpdate.Depot == null) { unitToUpdate.Depot = new DepotDTO() { DepotId = (int)depotId }; } else { unitToUpdate.Depot.DepotId = (int)depotId; } } drugUnits.UpdateUnit(unitToUpdate); } return(RedirectToAction("List", new { page })); }
private void AddDepotToUnit(DrugUnitDTO unit) { if (unit.Depot != null) { DepotDTO depotDTO = unitOfWork.Depots.GetById(unit.Depot.DepotId).ToDTO(); unit.Depot = depotDTO; } }
private void AddDrugTypeToUnit(DrugUnitDTO unit) { if (unit.DrugType != null) { DrugTypeDTO typeDTO = unitOfWork.DrugTypes.GetById(unit.DrugType.DrugTypeId).ToDTO(); unit.DrugType = typeDTO; } }
public static DrugUnit ToDAL(this DrugUnitDTO drugUnitDTO) { return(new DrugUnit() { DrugUnitId = drugUnitDTO.DrugUnitId, DrugTypeId = drugUnitDTO.DrugType?.DrugTypeId, DepotId = drugUnitDTO.Depot?.DepotId, PickNumber = drugUnitDTO.PickNumber }); }
public void UpdateUnit(DrugUnitDTO unitToUpdate) { drugUnits.Update(unitToUpdate.ToDAL()); unitOfWork.Commit(); }
public string UnitSummary(DrugUnitDTO unit) { return($"#{unit.DrugUnitId}, {unit.DrugType.DrugTypeName}, Pick num. {unit.PickNumber}"); }