Ejemplo n.º 1
0
        public SpecimenMappingDataDTO GetSpecimenMappingData(string spm_id)
        {
            log.MethodStart();
            SpecimenMappingDataDTO objModel = new SpecimenMappingDataDTO();

            using (var trans = _db.Database.BeginTransaction())
            {
                try
                {
                    var objReturn1 = _db.TRSpecimenMappings.FirstOrDefault(x => x.spm_id.ToString() == spm_id);

                    objModel = _mapper.Map <SpecimenMappingDataDTO>(objReturn1);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    // TODO: Handle failure
                    trans.Rollback();
                }
                finally
                {
                    trans.Dispose();
                }
            }


            log.MethodFinish();

            return(objModel);
        }
Ejemplo n.º 2
0
        public async Task <SpecimenMappingDataDTO> GetSpecimenMappingDataAsync(string spm_Id)
        {
            SpecimenMappingDataDTO SpecimenMapping = new SpecimenMappingDataDTO();

            SpecimenMapping = await _apiHelper.GetDataByIdAsync <SpecimenMappingDataDTO>("mapping_api/Get_SpecimenMappingData", spm_Id);

            return(SpecimenMapping);
        }
Ejemplo n.º 3
0
        public async Task <SpecimenMappingDataDTO> GetSpecimenMappingDataByModelAsync(SpecimenMappingDataDTO model)
        {
            SpecimenMappingDataDTO objList = new SpecimenMappingDataDTO();

            objList = await _apiHelper.GetDataByModelAsync <SpecimenMappingDataDTO, SpecimenMappingDataDTO>("mapping_api/Get_SpecimenMappingDataByModel", model);

            return(objList);
        }
Ejemplo n.º 4
0
        public async Task <SpecimenMappingDataDTO> SaveSpecimenMappingDataAsync(SpecimenMappingDataDTO model)
        {
            if (model.spm_id.Equals(Guid.Empty))
            {
                model.spm_id         = Guid.NewGuid();
                model.spm_status     = 'N';
                model.spm_flagdelete = false;
            }
            else
            {
                model.spm_status = 'E';
            }

            model.spm_updatedate = DateTime.Now;
            var specimenmapping = await _apiHelper.PostDataAsync <SpecimenMappingDataDTO>("mapping_api/Post_SaveSpecimenMappingData", model);

            return(specimenmapping);
        }
Ejemplo n.º 5
0
        public SpecimenMappingDataDTO GetSpecimenMappingDataWithModel(SpecimenMappingDataDTO model)
        {
            log.MethodStart();
            SpecimenMappingDataDTO objModel = new SpecimenMappingDataDTO();

            using (var trans = _db.Database.BeginTransaction())
            {
                try
                {
                    var objReturn1 = _db.TRSpecimenMappings.FirstOrDefault(x => x.spm_mappingid == model.spm_mappingid
                                                                           //&& x.spm_whonetcode == model.spm_whonetcode
                                                                           && x.spm_localspecimencode.ToUpper() == model.spm_localspecimencode.ToUpper()
                                                                           //&& x.spm_localspecimendesc == model.spm_localspecimendesc
                                                                           && x.spm_flagdelete == false);

                    if (objReturn1 != null)
                    {
                        objModel = _mapper.Map <SpecimenMappingDataDTO>(objReturn1);
                    }

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    // TODO: Handle failure
                    trans.Rollback();
                }
                finally
                {
                    trans.Dispose();
                }
            }


            log.MethodFinish();

            return(objModel);
        }
        public SpecimenMappingDataDTO Get_SpecimenMappingDataByModel([FromBody] SpecimenMappingDataDTO model)
        {
            var objReturn = _service.GetSpecimenMappingDataWithModel(model);

            return(objReturn);
        }
        public SpecimenMappingDataDTO Post_SaveSpecimenMappingData([FromBody] SpecimenMappingDataDTO model)
        {
            var objReturn = _service.SaveSpecimenMappingData(model);

            return(objReturn);
        }
Ejemplo n.º 8
0
        public SpecimenMappingDataDTO SaveSpecimenMappingData(SpecimenMappingDataDTO model)
        {
            log.MethodStart();

            var currentDateTime = DateTime.Now;
            SpecimenMappingDataDTO objReturn = new SpecimenMappingDataDTO();
            bool chkUpdate = false;

            using (var trans = _db.Database.BeginTransaction())
            {
                try
                {
                    var objModel = new TRSpecimenMapping();
                    objModel = _db.TRSpecimenMappings.FirstOrDefault(x => x.spm_id == model.spm_id);
                    if (objModel == null)
                    {
                        objModel = _mapper.Map <TRSpecimenMapping>(model);

                        objModel.spm_createdate = currentDateTime;
                        objModel.spm_updatedate = currentDateTime;
                        chkUpdate = true;
                        _db.TRSpecimenMappings.Add(objModel);
                    }
                    else
                    {
                        if (
                            objModel.spm_flagdelete != model.spm_flagdelete ||
                            objModel.spm_whonetcode != model.spm_whonetcode ||
                            objModel.spm_localspecimencode != model.spm_localspecimencode ||
                            objModel.spm_localspecimendesc != model.spm_localspecimendesc)
                        {
                            objModel.spm_status            = model.spm_status;
                            objModel.spm_flagdelete        = model.spm_flagdelete;
                            objModel.spm_whonetcode        = model.spm_whonetcode;
                            objModel.spm_localspecimencode = model.spm_localspecimencode;
                            objModel.spm_localspecimendesc = model.spm_localspecimendesc;
                            objModel.spm_updateuser        = model.spm_updateuser;
                            objModel.spm_updatedate        = currentDateTime;
                            chkUpdate = true;
                        }
                    }

                    if (chkUpdate == true)
                    {
                        #region Update Mapping Version..

                        var objMapping = _db.TRMappings.FirstOrDefault(x => x.mp_id == model.spm_mappingid);
                        if (objMapping != null)
                        {
                            objMapping = PrepareMappingUpdateVersion(objMapping, model.spm_updateuser, currentDateTime);
                        }
                        #endregion


                        #region Save Log Process ...
                        _db.LogProcesss.Add(new LogProcess()
                        {
                            log_usr_id     = (objModel.spm_updateuser ?? objModel.spm_createuser),
                            log_mnu_id     = "",
                            log_mnu_name   = "SpecimenMapping",
                            log_tran_id    = objModel.spm_id.ToString(),
                            log_action     = (objModel.spm_status == 'N' ? "New" : "Update"),
                            log_desc       = "Update SpecimenMapping ",
                            log_createuser = "******",
                            log_createdate = currentDateTime
                        });
                        #endregion
                    }

                    _db.SaveChanges();

                    trans.Commit();

                    objReturn = _mapper.Map <SpecimenMappingDataDTO>(objModel);
                }
                catch (Exception ex)
                {
                    // TODO: Handle failure
                    trans.Rollback();
                }
                finally
                {
                    trans.Dispose();
                }
            }

            log.MethodFinish();

            return(objReturn);
        }