Пример #1
0
        public WHONetMappingDataDTO GetWHONetMappingData(string wnm_id)
        {
            log.MethodStart();
            WHONetMappingDataDTO objModel = new WHONetMappingDataDTO();

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

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

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


            log.MethodFinish();

            return(objModel);
        }
Пример #2
0
        public async Task <WHONetMappingDataDTO> GetWHONetMappingDataByModelAsync(WHONetMappingDataDTO model)
        {
            WHONetMappingDataDTO objList = new WHONetMappingDataDTO();

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

            return(objList);
        }
Пример #3
0
        public async Task <WHONetMappingDataDTO> GetWHONetMappingDataAsync(string wnm_Id)
        {
            WHONetMappingDataDTO menu = new WHONetMappingDataDTO();

            menu = await _apiHelper.GetDataByIdAsync <WHONetMappingDataDTO>("mapping_api/Get_WHONetMappingData", wnm_Id);

            return(menu);
        }
Пример #4
0
        public async Task <WHONetMappingDataDTO> SaveWHONetMappingDataAsync(WHONetMappingDataDTO model)
        {
            if (model.wnm_id.Equals(Guid.Empty))
            {
                model.wnm_id         = Guid.NewGuid();
                model.wnm_status     = 'N';
                model.wnm_flagdelete = false;
            }
            else
            {
                model.wnm_status = 'E';
            }

            model.wnm_updatedate = DateTime.Now;
            var whonetmapping = await _apiHelper.PostDataAsync <WHONetMappingDataDTO>("mapping_api/Post_SaveWHONetMappingData", model);


            return(whonetmapping);
        }
Пример #5
0
        public WHONetMappingDataDTO GetWHONetMappingDataWithModel(WHONetMappingDataDTO model)
        {
            log.MethodStart();
            WHONetMappingDataDTO objModel = new WHONetMappingDataDTO();

            using (var trans = _db.Database.BeginTransaction())
            {
                try
                {
                    var objReturn1 = _db.TRWHONetMappings.FirstOrDefault(x => x.wnm_mappingid == model.wnm_mappingid &&
                                                                         (x.wnm_whonetfield == model.wnm_whonetfield ||
                                                                          x.wnm_originalfield == model.wnm_originalfield) &&
                                                                         x.wnm_flagdelete == false);

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

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


            log.MethodFinish();

            return(objModel);
        }
        public WHONetMappingDataDTO Post_SaveWHONetMappingData([FromBody] WHONetMappingDataDTO model)
        {
            var objReturn = _service.SaveWHONetMappingData(model);

            return(objReturn);
        }
        public WHONetMappingDataDTO Get_WHONetMappingDataByModel([FromBody] WHONetMappingDataDTO model)
        {
            var objReturn = _service.GetWHONetMappingDataWithModel(model);

            return(objReturn);
        }
Пример #8
0
        public WHONetMappingDataDTO SaveWHONetMappingData(WHONetMappingDataDTO model)
        {
            log.MethodStart();

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

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

                        objModel.wnm_createdate = currentDateTime;
                        objModel.wnm_updatedate = currentDateTime;

                        _db.TRWHONetMappings.Add(objModel);
                        chkUpdate = true;
                    }
                    else
                    {
                        if (
                            objModel.wnm_flagdelete != model.wnm_flagdelete ||
                            objModel.wnm_whonetfield != model.wnm_whonetfield ||
                            objModel.wnm_originalfield != model.wnm_originalfield ||
                            objModel.wnm_type != model.wnm_type ||
                            objModel.wnm_fieldlength != model.wnm_fieldlength ||
                            objModel.wnm_fieldformat != model.wnm_fieldformat ||
                            objModel.wnm_encrypt != model.wnm_encrypt ||
                            objModel.wnm_mandatory != model.wnm_mandatory ||
                            objModel.wnm_antibioticcolumn != model.wnm_antibioticcolumn ||
                            objModel.wnm_antibiotic != model.wnm_antibiotic)
                        {
                            objModel.wnm_status           = model.wnm_status;
                            objModel.wnm_flagdelete       = model.wnm_flagdelete;
                            objModel.wnm_whonetfield      = model.wnm_whonetfield;
                            objModel.wnm_originalfield    = model.wnm_originalfield;
                            objModel.wnm_type             = model.wnm_type;
                            objModel.wnm_fieldlength      = model.wnm_fieldlength;
                            objModel.wnm_fieldformat      = model.wnm_fieldformat;
                            objModel.wnm_encrypt          = model.wnm_encrypt;
                            objModel.wnm_mandatory        = model.wnm_mandatory;
                            objModel.wnm_antibioticcolumn = model.wnm_antibioticcolumn;
                            objModel.wnm_antibiotic       = model.wnm_antibiotic;
                            objModel.wnm_updateuser       = model.wnm_updateuser;
                            objModel.wnm_updatedate       = currentDateTime;
                            chkUpdate = true;
                        }
                    }
                    if (chkUpdate == true)
                    {
                        #region Update Mapping Version..

                        var objMapping = _db.TRMappings.FirstOrDefault(x => x.mp_id == model.wnm_mappingid);
                        if (objMapping != null)
                        {
                            objMapping = PrepareMappingUpdateVersion(objMapping, model.wnm_updateuser, currentDateTime);
                        }

                        #endregion

                        #region Save Log Process ...
                        _db.LogProcesss.Add(new LogProcess()
                        {
                            log_usr_id     = (objModel.wnm_updateuser ?? objModel.wnm_createuser),
                            log_mnu_id     = "",
                            log_mnu_name   = "WHONetMapping",
                            log_tran_id    = objModel.wnm_id.ToString(),
                            log_action     = (objModel.wnm_status == 'N' ? "New" : "Update"),
                            log_desc       = "Update WHONetMapping ",
                            log_createuser = "******",
                            log_createdate = currentDateTime
                        });
                        #endregion
                    }
                    _db.SaveChanges();

                    trans.Commit();

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

            log.MethodFinish();

            return(objReturn);
        }