コード例 #1
0
        public IActionResult GetPartyId(int PartyId)
        {
            try
            {
                var    admin  = HttpContext.User;
                bool   status = false;
                string message;

                if (admin.HasClaim(c => c.Type == "TokenType"))
                {
                    if (admin.Claims.FirstOrDefault(c => c.Type == "TokenType").Value == "Login")
                    {
                        PartyCreatedResponseModel data = _partyBusiness.GetPartyById(PartyId);

                        if (data != null)
                        {
                            status  = true;
                            message = "Here is the Party Details";
                            return(Ok(new { status, message, data }));
                        }
                        message = "Unable to get the Party Details";
                        return(Ok(new { status, message }));
                    }
                }
                message = "Invalid Token";
                return(BadRequest(new { status, message }));
            }
            catch (Exception e)
            {
                return(BadRequest(new { e.Message }));
            }
        }
コード例 #2
0
        /// <summary>
        /// It return all the party.
        /// </summary>
        /// <returns>Return Party</returns>
        public List <PartyCreatedResponseModel> GetAllParty()
        {
            try
            {
                int           statusCode;
                SqlDataReader reader;
                List <PartyCreatedResponseModel> createParties = null;

                using (SqlConnection connection = new SqlConnection(sqlConnection))
                {
                    SqlCommand sqlCommand = new SqlCommand("spParty", connection)
                    {
                        CommandType = System.Data.CommandType.StoredProcedure
                    };
                    sqlCommand.Parameters.AddWithValue("@PartyId", -1);
                    sqlCommand.Parameters.AddWithValue("@Name", "");
                    sqlCommand.Parameters.AddWithValue("@ActionType", "GetAll");

                    SqlParameter cmdExecuteSuccess = sqlCommand.Parameters.Add("@return_value", System.Data.SqlDbType.Int);
                    cmdExecuteSuccess.Direction = System.Data.ParameterDirection.ReturnValue;

                    connection.Open();

                    reader     = sqlCommand.ExecuteReader();
                    statusCode = Convert.ToInt32(sqlCommand.Parameters["@return_Value"].Value);

                    if (statusCode == 0)
                    {
                        createParties = new List <PartyCreatedResponseModel>();
                        while (reader.Read())
                        {
                            PartyCreatedResponseModel createParty = new PartyCreatedResponseModel
                            {
                                PartyId    = Convert.ToInt32(reader[0]),
                                Name       = reader[1].ToString(),
                                CreatedAt  = Convert.ToDateTime(reader[2]),
                                ModifiedAt = Convert.ToDateTime(reader[3])
                            };
                            createParties.Add(createParty);
                        }
                    }
                }

                return(createParties);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
コード例 #3
0
        /// <summary>
        /// It Return the specific party Data
        /// </summary>
        /// <param name="PartyId">Party Id</param>
        /// <returns>It Return Party Created Response Model</returns>
        public PartyCreatedResponseModel GetPartyById(int PartyId)
        {
            try
            {
                SqlDataReader             reader;
                PartyCreatedResponseModel createParty = null;

                using (SqlConnection connection = new SqlConnection(sqlConnection))
                {
                    SqlCommand sqlCommand = new SqlCommand("spParty", connection)
                    {
                        CommandType = System.Data.CommandType.StoredProcedure
                    };
                    sqlCommand.Parameters.AddWithValue("@PartyId", PartyId);
                    sqlCommand.Parameters.AddWithValue("@Name", "");
                    sqlCommand.Parameters.AddWithValue("@ActionType", "GetById");

                    connection.Open();

                    reader = sqlCommand.ExecuteReader();

                    if (reader.HasRows)
                    {
                        createParty = new PartyCreatedResponseModel();

                        while (reader.Read())
                        {
                            createParty.PartyId    = Convert.ToInt32(reader[0]);
                            createParty.Name       = reader[1].ToString();
                            createParty.CreatedAt  = Convert.ToDateTime(reader[2]);
                            createParty.ModifiedAt = Convert.ToDateTime(reader[3]);
                        }
                    }
                }

                return(createParty);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
コード例 #4
0
        public IActionResult CreateParty(CreatePartyRequestModel createPartyRequest)
        {
            try
            {
                var    admin  = HttpContext.User;
                bool   status = false;
                string message;

                if (admin.HasClaim(c => c.Type == "TokenType"))
                {
                    if (admin.Claims.FirstOrDefault(c => c.Type == "TokenType").Value == "Login")
                    {
                        CreatePartyResponseModel createParty = _partyBusiness.CreateParty(createPartyRequest);

                        if (createParty != null)
                        {
                            if (createParty.ErrorResponse.ErrorStatus)
                            {
                                message = createParty.ErrorResponse.Message;
                                return(Ok(new { status, message }));
                            }
                            status  = true;
                            message = "Party Created Successfully";
                            PartyCreatedResponseModel data = createParty.PartyCreated;
                            return(Ok(new { status, message, data }));
                        }
                        message = "Unable to Create Party";
                        return(Ok(new { status, message }));
                    }
                }

                message = "Invalid Token";
                return(BadRequest(new { status, message }));
            }
            catch (Exception e)
            {
                return(BadRequest(new { e.Message }));
            }
        }