Beispiel #1
0
        public IEnumerable <AgentDocumentstbl> AgentsDocument(int type, AgentDocumentstbl at)
        {
            List <AgentDocumentstbl> obj = new List <AgentDocumentstbl>();

            try
            {
                MySqlCommand cmd = new MySqlCommand("Sp_AgentDocuments", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("type", type);
                cmd.Parameters.AddWithValue("pDocumentId", at.DocumentId);
                cmd.Parameters.AddWithValue("pAgentId", at.AgentId);
                cmd.Parameters.AddWithValue("pDocumentName", at.DocumentName);
                cmd.Parameters.AddWithValue("pFileName", at.FileName);
                cmd.Parameters.AddWithValue("pIsActive", at.IsActive);
                cmd.Parameters.AddWithValue("pCreatedBy", at.CreatedBy);
                cmd.Parameters.AddWithValue("pCreatedDate", at.CreatedDate);
                cmd.Parameters.AddWithValue("pUpdatedBy", at.UpdatedBy);
                cmd.Parameters.AddWithValue("pUpdatedDate", at.UpdatedDate);
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                MySqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    obj.Add(new AgentDocumentstbl
                    {
                        DocumentId   = Convert.ToInt32(dr["DocumentId"]),
                        AgentId      = Convert.ToInt32(dr["AgentId"]),
                        DocumentName = dr["DocumentName"].ToString(),
                        FileName     = dr["FileName"].ToString(),
                    });
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                obj.Add(new AgentDocumentstbl
                {
                    Message      = "Error",
                    ErrorMessage = ex.Message,
                });
            }
            finally
            {
                con.Close();
            }
            return(obj);
        }
Beispiel #2
0
        public IEnumerable <AgentDocs> AgentsDocsInsert(int type, AgentDocs ad)
        {
            List <AgentDocs> obj = new List <AgentDocs>();

            try
            {
                MySqlCommand cmd = new MySqlCommand("Sp_Registration", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("type", type);
                cmd.Parameters.AddWithValue("pAgentID", ad.Agentstc.AgentID);
                cmd.Parameters.AddWithValue("pAgencyName", ad.Agentstc.AgencyName);
                cmd.Parameters.AddWithValue("pAgencyEmail", ad.Agentstc.AgencyEmail);
                cmd.Parameters.AddWithValue("pFirstName", ad.Agentstc.FirstName);
                cmd.Parameters.AddWithValue("pLastName", ad.Agentstc.LastName);
                cmd.Parameters.AddWithValue("pContactName", ad.Agentstc.ContactName);
                cmd.Parameters.AddWithValue("pMobileNo", ad.Agentstc.MobileNo);
                cmd.Parameters.AddWithValue("pCategoryId", ad.Agentstc.CategoryId);
                cmd.Parameters.AddWithValue("pWebsite", ad.Agentstc.Website);
                cmd.Parameters.AddWithValue("pAddress", ad.Agentstc.Address);
                cmd.Parameters.AddWithValue("pCountryId", ad.Agentstc.CountryId);
                cmd.Parameters.AddWithValue("pCityId", ad.Agentstc.CityId);
                cmd.Parameters.AddWithValue("pPreferredCurrency", ad.Agentstc.PreferredCurrency);
                cmd.Parameters.AddWithValue("pPincode", ad.Agentstc.Pincode);
                //cmd.Parameters.AddWithValue("pAgencyLogo", ad.Agentstc.AgencyLogo);
                cmd.Parameters.AddWithValue("pIATAStatus", ad.Agentstc.IATAStatus);
                cmd.Parameters.AddWithValue("pIATARegNo", ad.Agentstc.IATARegNo);
                cmd.Parameters.AddWithValue("pReferredBy", ad.Agentstc.ReferredBy);
                cmd.Parameters.AddWithValue("pIsActive", ad.Agentstc.IsActive);
                cmd.Parameters.AddWithValue("pCreatedBy", ad.Agentstc.CreatedBy);
                cmd.Parameters.AddWithValue("pCreatedDate", ad.Agentstc.CreatedDate);
                cmd.Parameters.AddWithValue("pUpdatedBy", ad.Agentstc.UpdatedBy);
                cmd.Parameters.AddWithValue("pUpdatedDate", ad.Agentstc.UpdatedDate);
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                var i    = cmd.ExecuteNonQuery();
                var last = cmd.LastInsertedId;
                if (i > 0)
                {
                    AgentDocumentstbl ads = new AgentDocumentstbl();
                    ads.AgentId      = (int)last;
                    ads.DocumentName = ad.AgentsDocumentstc.DocumentName;
                    ads.FileName     = ad.AgentsDocumentstc.FileName;
                    ads.IsActive     = ad.AgentsDocumentstc.IsActive;
                    ads.CreatedBy    = ad.AgentsDocumentstc.CreatedBy;
                    ads.CreatedDate  = ad.AgentsDocumentstc.CreatedDate;
                    AgentsDocument(3, ads);

                    //foreach ( var p in ad.AgentsDocumentstc)
                    //{
                    //    AgentDocumentstbl ads = new AgentDocumentstbl();
                    //    ads.AgentId = (int)last;
                    //    ads.DocumentName = p.DocumentName;
                    //    ads.FileName = p.FileName;
                    //    ads.IsActive = p.IsActive;
                    //    ads.CreatedBy = p.CreatedBy;
                    //    ads.CreatedDate = p.CreatedDate;
                    //    AgentsDocument(3, ads);
                    //}
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                con.Close();
            }
            return(obj);
        }