Пример #1
0
        public static RawMaterialQCSpecificGravityDTO MapToDTO(TPO.DL.Models.RawMaterialSpecificGravity dbo)
        {
            RawMaterialQCSpecificGravityDTO dto = new RawMaterialQCSpecificGravityDTO
            {
                ID = dbo.ID,
                RawMaterialQCID    = dbo.RawMaterialQCID,
                RawMaterialCode    = dbo.RawMaterialQC.RawMaterialReceived.RawMaterial.Code,
                RawMaterialLotCode = dbo.RawMaterialQC.RawMaterialReceived.LotNumber,
                AverageGravity     = dbo.RawMaterialQC.SpecGrav ?? 0.00,
                DenIso             = dbo.DenIso,
                LabTechUserID      = dbo.LabTechUserID,
                DateEntered        = dbo.DateEntered,
                EnteredBy          = dbo.EnteredBy,
                LastModified       = dbo.LastModified,
                ModifiedBy         = dbo.ModifiedBy,
                RawMaterialSpecificGravityDetails = new List <RawMaterialQCSpecificGravityDetailDTO>()
            };

            foreach (RawMaterialSpecificGravityDetail detailLine in dbo.RawMaterialSpecificGravityDetails)
            {
                RawMaterialQCSpecificGravityDetailDTO dtoDetail = new RawMaterialQCSpecificGravityDetailDTO()
                {
                    ID = detailLine.ID,
                    RawMaterialSpecGravID = detailLine.RawMaterialSpecGravID,
                    Order        = detailLine.Order,
                    Submerged    = detailLine.Submerged,
                    Value        = detailLine.Value,
                    DateEntered  = dbo.DateEntered,
                    EnteredBy    = dbo.EnteredBy,
                    LastModified = dbo.LastModified,
                    ModifiedBy   = dbo.ModifiedBy
                };

                dto.RawMaterialSpecificGravityDetails.Add(dtoDetail);
            }
            return(dto);
        }
Пример #2
0
        public void Add(RawMaterialQCSpecificGravityDTO dto)
        {
            try
            {
                using (var context = new TPOMVCApplicationEntities())
                {
                    var newEntity = new TPO.DL.Models.RawMaterialSpecificGravity();
                    newEntity.RawMaterialQCID = dto.RawMaterialQCID;


                    newEntity.DateEntered  = dto.DateEntered ?? DateTime.Now;
                    newEntity.EnteredBy    = dto.EnteredBy;
                    newEntity.LastModified = dto.LastModified ?? DateTime.Now;
                    newEntity.ModifiedBy   = dto.ModifiedBy;
                    context.RawMaterialSpecificGravities.Add(newEntity);
                    context.SaveChanges();
                    //need to return the new record id
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }