public void Create(POFICDTO POFICDTO)
        {
            POFIC obj = _mapper.Map <POFIC>(POFICDTO);

            obj.CreatedDate = DateTime.Now;
            _unitOfWork.POFIC.Create(obj);
            _unitOfWork.SaveChanges();
        }
        public void Update(POFICDTO POFICDTO)
        {
            int   ID       = POFICDTO.ID;
            POFIC pipeline = _unitOfWork.POFIC.FindById(ID);

            if (pipeline != null)
            {
                int yearInService = (from p in _unitOfWork.PipeMaster.FindAll().Where(p => p.EquipmentNo == pipeline.EquipmentNo)
                                     select p.YearInService
                                     ).FirstOrDefault();


                int?lastMeasuredYear = (from p in _unitOfWork.PipeMaster.FindAll().Where(p => p.EquipmentNo == pipeline.EquipmentNo)
                                        select p.LastMeasuredYear_LMY
                                        ).FirstOrDefault();

                if (!pipeline.AnalysisYear.HasValue)
                {
                    pipeline.AnalysisYear = DateTime.Now.Year;
                }
                pipeline.InjectionPoints  = POFICDTO.InjectionPoints;
                pipeline.TheoriticalCR    = POFICDTO.TheoriticalCR;
                pipeline.EffectiveCR      = POFICDTO.EffectiveCR;
                pipeline.EffectiveAge     = POFICDTO.EffectiveAge;
                pipeline.MeasuredLCR      = POFICDTO.MeasuredLCR;
                pipeline.MeasuredSCR      = POFICDTO.MeasuredSCR;
                pipeline.UseMeasuredLCR   = POFICDTO.UseMeasuredLCR;
                pipeline.UseMeasuredSCR   = POFICDTO.UseMeasuredSCR;
                pipeline.VeryHigh         = POFICDTO.VeryHigh;
                pipeline.High             = POFICDTO.High;
                pipeline.Medium           = POFICDTO.Medium;
                pipeline.Low              = POFICDTO.Low;
                pipeline.Found            = POFICDTO.Found;
                pipeline.DamageFactor     = POFICDTO.DamageFactor;
                pipeline.POF              = POFICDTO.POF;
                pipeline.LastMeasuredYear = POFICDTO.LastMeasuredYear;

                pipeline.ModifiedBy   = POFICDTO.ModifiedBy;
                pipeline.ModifiedDate = DateTime.Now;
                // EffectiveCR
                if (pipeline.UseMeasuredLCR == "Y")
                {
                    pipeline.EffectiveCR = pipeline.MeasuredLCR;
                }
                else if (pipeline.UseMeasuredSCR == "Y")
                {
                    pipeline.EffectiveCR = pipeline.MeasuredSCR;
                }
                else if (pipeline.InjectionPoints == "Y")
                {
                    pipeline.EffectiveCR = 2 * pipeline.TheoriticalCR;
                }
                else if (pipeline.InjectionPoints == "N")
                {
                    pipeline.EffectiveCR = pipeline.TheoriticalCR;
                }

                // EffectiveAge
                if (lastMeasuredYear.HasValue)
                {
                    pipeline.EffectiveAge = pipeline.AnalysisYear - lastMeasuredYear;
                }
                else
                {
                    pipeline.EffectiveAge = pipeline.AnalysisYear - yearInService;
                }
            }
            _unitOfWork.POFIC.Update(pipeline);
            _unitOfWork.SaveChanges();

            Update(pipeline.EquipmentNo, pipeline.AnalysisYear.Value);
        }
 public void Put([FromBody] POFICDTO POFICDTO)
 {
     _POFICService.Update(POFICDTO);
 }
 public void Post([FromBody] POFICDTO POFICDTO)
 {
     _POFICService.Create(POFICDTO);
 }