public IActionResult FetchLookup([FromRoute] string ApiKey, [FromBody] LookupObj Param)
        {
            IActionResult  response;
            LookupResponse resp = new LookupResponse();

            try
            {
                #region Call Get_Data_Set

                LookupDAO ObjResponseDAO = new LookupDAO(_ConStr);
                DataSet   ds             = ObjResponseDAO.FetchLookup(ApiKey, Param);

                #endregion

                var lookups = (from r in ds.Tables[0].AsEnumerable()
                               select new Lookup()
                {
                    lookup_id = r.Field <int>("lookup_id"),
                    lookup_code = r.Field <string>("lookup_code"),
                    lookup_description = r.Field <string>("lookup_description"),
                    lookup_name = r.Field <string>("lookup_name")
                }).ToList();


                resp.statuscode = (int)Common.ResponseStatusCode.Success;
                resp.message    = "success";
                resp.rows       = lookups;

                response = Ok(resp);
            }
            catch (Exception ex)
            {
                Common       c     = new Common();
                ExceptionObj exobj = c.GetExceptionObjBase(ex);
                exobj.form_name = "BodyController";
                exobj.page_url  = "api/Body/List";

                int    ReturnVal;
                string ReturnMsg;

                ExceptionDAO exd = new ExceptionDAO(_ConStr);
                exd.SetExceptionLog(ApiKey, exobj, out ReturnVal, out ReturnMsg);

                resp.statuscode = (int)Common.ResponseStatusCode.Exception;
                resp.message    = ex.Message.ToString();

                response = BadRequest(resp);
            }

            return(response);
        }
Beispiel #2
0
        /// <summary> Get Loookup By LookupId </summary>
        /// <param name="LookupId">The Integer object</param>
        /// <returns>LookupObj object</returns>
        public LookupObj GetLookupById(int LookupId)
        {
            Logging.LogDebugMessage("Method: GetLookupById, MethodType: Get, Layer: LookupsDAL, Parameters: LookupId = " + LookupId.ToString());
            var       dataSet   = new DataSet();
            LookupObj lookupObj = new LookupObj();

            try
            {
                using (var command = new SqlCommand())
                {
                    command.Connection  = new SqlConnection(this.ConnectionString);
                    command.CommandText = "USP_GetLookupById";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@LookupId", Value = LookupId
                    });
                    using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                    {
                        adapter.Fill(dataSet);
                        if (dataSet != null && dataSet.Tables.Count > 0)
                        {
                            lookupObj = EntityCollectionHelper.ConvertTo <LookupObj>(dataSet.Tables[0]).FirstOrDefault();
                            lookupObj.lookupDetails = EntityCollectionHelper.ConvertTo <LookupDetails>(dataSet.Tables[1]).ToList();
                        }
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                Logging.LogErrorMessage("Method: GetLookupById, Layer: LookupsDAL, Stack Trace: " + sqlEx.ToString());
                throw;
            }
            catch (Exception ex)
            {
                Logging.LogErrorMessage("Method: GetLookupById, Layer: LookupsDAL, Stack Trace: " + ex.ToString());
                throw;
            }

            return(lookupObj);
        }
Beispiel #3
0
        public DataSet FetchLookup(string ApiKey, LookupObj Param)
        {
            DataSet ds = null;

            try
            {
                List <DBParameter> pList = new List <DBParameter>();
                pList.Add(new DBParameter("api_Key", SqlDbType.VarChar, 255, ParameterDirection.Input, ApiKey));
                pList.Add(new DBParameter("studio_id", SqlDbType.BigInt, 0, ParameterDirection.Input, Param.studio_id));
                pList.Add(new DBParameter("lookup_group_id", SqlDbType.BigInt, 0, ParameterDirection.Input, Param.lookup_group_id));
                pList.Add(new DBParameter("parent_lookup_id", SqlDbType.BigInt, 0, ParameterDirection.Input, Param.parent_lookup_id));
                pList.Add(new DBParameter("lookup_id", SqlDbType.BigInt, 0, ParameterDirection.Input, Param.lookup_id));

                objDAO = new DAO(_constr);

                ds = objDAO.GetDataSet("dbo.Get_LOOKUP", DAO.QueryType.StoredProcedure, pList);

                return(ds);
            }
            catch (Exception)
            {
                throw;
            }
        }