Ejemplo n.º 1
0
        public ActionResult <DataResponseExt <CountryModel> > Get(string name = null, string code = null, RecordStatus?status = null)
        {
            DataResponseExt <CountryModel> response = new DataResponseExt <CountryModel>();
            List <CountryModel>            _DTO     = null;

            try
            {
                var _countries = _unitOfWork.Users.Search(name, code, status);
                _DTO = _mapper.Map <List <CountryModel> >(_countries);

                response.Code        = ResponseCode.SUCCESS;
                response.Description = ResponseDescription.SUCCESS;
                response.Message     = null;
                response.Data        = _DTO;
                return(Ok(response));
            }
            catch (Exception ex)
            {
                Guid _ErrorCode = Guid.NewGuid();
                Log.Error("Fatal Error [{ErrorCode}]: {Message}", _ErrorCode, ex.Message);
                response.Code        = ResponseCode.SYSTEM_ERROR;
                response.Description = ResponseDescription.SYSTEM_ERROR;
                response.Message     = $"System Error: Something went wrong here! Kindly contact the support with this error code [{_ErrorCode}]";
                response.Data        = _DTO;
                return(BadRequest(response));
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <DataResponseExt <LGAModel> > > GetAsync(string name = null, string code = null, string countryId = null, RecordStatus?status = null)
        {
            DataResponseExt <LGAModel> response = new DataResponseExt <LGAModel>();
            List <LGAModel>            _DTO     = null;

            try
            {
                State _theState = null;
                if (countryId != null)
                {
                    _theState = await _unitOfWork.States.GetAsync(countryId).ConfigureAwait(false);
                }

                var _LGAs = _unitOfWork.LGAs.Search(name, code, _theState, status);
                _DTO = _mapper.Map <List <LGAModel> >(_LGAs);

                response.Code        = ResponseCode.SUCCESS;
                response.Description = ResponseDescription.SUCCESS;
                response.Message     = null;
                response.Data        = _DTO;
                return(Ok(response));
            }
            catch (Exception ex)
            {
                Guid _ErrorCode = Guid.NewGuid();
                Log.Error("Fatal Error [{ErrorCode}]: {Message}", _ErrorCode, ex.Message);
                response.Code        = ResponseCode.SYSTEM_ERROR;
                response.Description = ResponseDescription.SYSTEM_ERROR;
                response.Message     = $"System Error: Something went wrong here! Kindly contact the support with this error code [{_ErrorCode}]";
                response.Data        = _DTO;
                return(BadRequest(response));
            }
        }
Ejemplo n.º 3
0
        public IActionResult GetAllByLoaiCaNhan(string term, int loai, string id = "")
        {
            DataResponseExt res = new DataResponseExt();

            try
            {
                var            tupe              = GetByLoai(term, loai, id);
                var            shared_data       = tupe.Item1;
                var            thuoc_tinh_da_luu = tupe.Item2;
                List <dynamic> lst_kvp_data_luu  = new List <dynamic>();
                foreach (var item in thuoc_tinh_da_luu)
                {
                    lst_kvp_data_luu.Add(new { k = item, v = 0 });
                }
                var private_data = QLCUNL.BL.ThuocTinhBL.Search(app_id, user, term, loai, (int)ThuocTinhType.PRIVATE, 1, out long total_recs, out string msg, 9999, (is_sys_admin || is_app_admin));
                var list         = private_data.Concat(shared_data).ToList();
                res.data = list.OrderBy(x => x.nhom);


                if (!string.IsNullOrEmpty(id))
                {
                    string id_full = $"{((LoaiThuocTinh)loai).ToString()}_{id}";
                    var    gia_tri_thuoc_tinh_rieng_cu = QLCUNL.BL.ThuocTinhDuLieuBL.GetIdThuocTinhByIdObj(app_id, id, (LoaiThuocTinh)loai, user);
                    if (gia_tri_thuoc_tinh_rieng_cu != null)
                    {
                        foreach (var item in gia_tri_thuoc_tinh_rieng_cu)
                        {
                            lst_kvp_data_luu.Add(new { k = item, v = 1 });
                        }
                    }
                }
                res.value   = lst_kvp_data_luu;
                res.success = res.data != null;
            }
            catch (Exception ex)
            {
                res.msg = ex.Message; res.success = false;
            }

            return(Ok(res));
        }
Ejemplo n.º 4
0
        public IActionResult GetAllByLoaiShared(string term, int loai, string id = "")
        {
            DataResponseExt res = new DataResponseExt();

            try
            {
                res.data  = QLCUNL.BL.ThuocTinhBL.Search(app_id, string.Empty, term, loai, (int)ThuocTinhType.SHARED, 1, out long total_recs, out string msg).OrderBy(x => x.nhom);
                res.value = new List <int>();
                if (!string.IsNullOrEmpty(id))
                {
                    List <int> thuoc_tinh = new List <int>();
                    switch ((LoaiThuocTinh)loai)
                    {
                    case LoaiThuocTinh.CONG_TY:
                        var cong_ty = QLCUNL.BL.CongTyBL.GetById(id);
                        if (cong_ty != null)
                        {
                            thuoc_tinh = cong_ty.thuoc_tinh;
                        }
                        break;

                    case LoaiThuocTinh.USER_JOB:
                        var user_job = QLCUNL.BL.UserJobBL.GetById(id);
                        if (user_job != null)
                        {
                            thuoc_tinh = user_job.thuoc_tinh;
                        }
                        break;

                    case LoaiThuocTinh.NOTE_UNG_VIEN:
                        var note_ung_vien = QLCUNL.BL.NoteUngVienBL.GetById(id);
                        if (note_ung_vien != null)
                        {
                            thuoc_tinh = note_ung_vien.thuoc_tinh;
                        }
                        break;

                    case LoaiThuocTinh.UNG_VIEN:
                        var ung_vien = QLCUNL.BL.UngVienBL.GetById(id);
                        if (ung_vien != null)
                        {
                            thuoc_tinh = ung_vien.thuoc_tinh;
                        }
                        break;

                    case LoaiThuocTinh.JOB:
                        var job = QLCUNL.BL.JobBL.GetById(id);
                        if (job != null)
                        {
                            thuoc_tinh = job.thuoc_tinh;
                        }
                        break;

                    case LoaiThuocTinh.NOTE_UNG_VIEN_JOB:
                        var note_ung_vien_job = QLCUNL.BL.NoteUngVienJobBL.GetById(id);
                        if (note_ung_vien_job != null)
                        {
                            thuoc_tinh = note_ung_vien_job.thuoc_tinh;
                        }
                        break;
                    }

                    res.value = thuoc_tinh ?? new List <int>();
                }
                res.success = res.data != null;
            }
            catch (Exception ex)
            {
                res.msg = ex.Message; res.success = false;
            }

            return(Ok(res));
        }