public int Add(RawMaterialQCRedHoldDTO dto) { int returnID = -1; try { using (var context = new TPOMVCApplicationEntities()) { var newEntity = new TPO.DL.Models.RawMaterialQCRedHold(); newEntity.RawMaterialQCID = dto.RawMaterialQCID; newEntity.PlantID = dto.PlantID; newEntity.RawMaterialReceivedID = dto.RawMaterialReceivedID; newEntity.QCTechID = dto.QCTechID; newEntity.SupervisorID = dto.SupervisorID; newEntity.LeadOperatorID = dto.LeadOperatorID; newEntity.RedDate = dto.RedDate; newEntity.FailPropertyID = dto.FailPropertyID; newEntity.Zone = dto.Zone; newEntity.RedComments = dto.RedComments; newEntity.RedCorrectionAction = dto.RedCorrectionAction; newEntity.HoldDate = dto.HoldDate; newEntity.HoldLotNumber = dto.HoldLotNumber; newEntity.HoldComments = dto.HoldComments; newEntity.ManagerID = dto.ManagerID; newEntity.ManagerDate = dto.ManagerDate; newEntity.ManagerComments = dto.ManagerComments; newEntity.PrimeBoxCar = dto.PrimeBoxCar; newEntity.PrimeUOM = dto.PrimeUOM; newEntity.ReworkBoxCar = dto.ReworkBoxCar; newEntity.ReworkUOM = dto.ReworkUOM; newEntity.ScrapBoxCar = dto.ScrapBoxCar; newEntity.ScrapUOM = dto.ScrapUOM; newEntity.DateEntered = dto.DateEntered ?? DateTime.Now; newEntity.EnteredBy = dto.EnteredBy; newEntity.LastModified = dto.LastModified ?? DateTime.Now; newEntity.ModifiedBy = dto.ModifiedBy; context.RawMaterialQCRedHolds.Add(newEntity); context.SaveChanges(); //need to return the new record id //easy to do once we update to stored procs returnID = newEntity.ID; } } catch (DbEntityValidationException ex) { throw; } return(returnID); }
public static RawMaterialQCRedHoldDTO MapToDTO(TPO.DL.Models.RawMaterialQCRedHold dbo) { RawMaterialQCRedHoldDTO dto = new RawMaterialQCRedHoldDTO { ID = dbo.ID, RawMaterialQCID = dbo.RawMaterialQCID ?? -1, PlantID = dbo.PlantID, RawMaterialReceivedID = dbo.RawMaterialReceivedID, QCTechID = dbo.QCTechID, SupervisorID = dbo.SupervisorID, LeadOperatorID = dbo.LeadOperatorID, RedDate = dbo.RedDate, FailPropertyID = dbo.FailPropertyID, Zone = dbo.Zone, RedComments = dbo.RedComments, RedCorrectionAction = dbo.RedCorrectionAction, HoldDate = dbo.HoldDate, HoldLotNumber = dbo.HoldLotNumber, HoldComments = dbo.HoldComments, ManagerID = dbo.ManagerID, ManagerDate = dbo.ManagerDate, ManagerComments = dbo.ManagerComments, PrimeBoxCar = (float)dbo.PrimeBoxCar, PrimeUOM = (float)dbo.PrimeUOM, ReworkBoxCar = (float)dbo.ReworkBoxCar, ReworkUOM = (float)dbo.ReworkUOM, ScrapBoxCar = (float)dbo.ScrapBoxCar, ScrapUOM = (float)dbo.ScrapUOM, DateEntered = dbo.DateEntered, EnteredBy = dbo.EnteredBy, LastModified = dbo.LastModified, ModifiedBy = dbo.ModifiedBy }; return(dto); }