public BDMSurveyDetailDTO GetAppointmentDetailByClientId(BDMAppointmentGetIdDTO objSurveyAppointmentDetail)
        {
            BDMSurveyDetailDTO             surveyDetail            = new BDMSurveyDetailDTO();
            List <BDMSurveyCompetitorsDTO> surveyCompetitorsDetail = new List <BDMSurveyCompetitorsDTO>();
            List <BDMSurveyRequirementDTO> surveyRequirementDetail = new List <BDMSurveyRequirementDTO>();
            List <BDMAppointmentReportDTO> surveyReportDetail      = new List <BDMAppointmentReportDTO>();

            using (DbLayer dbLayer = new DbLayer())
            {
                SqlCommand SqlCmd = new SqlCommand("spSelectAppointmentDetailById");
                SqlCmd.CommandType = CommandType.StoredProcedure;
                SqlCmd.Parameters.AddWithValue("@Id", objSurveyAppointmentDetail.ClientId);
                SqlCmd.Parameters.AddWithValue("@ActionBy", objSurveyAppointmentDetail.ActionBy);
                surveyDetail = dbLayer.GetEntityList <BDMSurveyDetailDTO>(SqlCmd).FirstOrDefault();
            }
            using (DbLayer dbLayer = new DbLayer())
            {
                SqlCommand SqlCmd1 = new SqlCommand("spSelectCompetitorsById");
                SqlCmd1.CommandType = CommandType.StoredProcedure;
                SqlCmd1.Parameters.AddWithValue("@ClientId", objSurveyAppointmentDetail.ClientId);
                SqlCmd1.Parameters.AddWithValue("@ActionBy", objSurveyAppointmentDetail.ActionBy);
                surveyCompetitorsDetail = dbLayer.GetEntityList <BDMSurveyCompetitorsDTO>(SqlCmd1);
                surveyDetail.surveyCompetitorsDetail = surveyCompetitorsDetail;
            }

            using (DbLayer dbLayer = new DbLayer())
            {
                SqlCommand SqlCmd2 = new SqlCommand("spSelectRequirementDetailsById");
                SqlCmd2.CommandType = CommandType.StoredProcedure;
                SqlCmd2.Parameters.AddWithValue("@ClientId", objSurveyAppointmentDetail.ClientId);
                SqlCmd2.Parameters.AddWithValue("@ActionBy", objSurveyAppointmentDetail.ActionBy);
                surveyRequirementDetail           = dbLayer.GetEntityList <BDMSurveyRequirementDTO>(SqlCmd2);
                surveyDetail.BDMSurveyRequirement = surveyRequirementDetail;
            }

            using (DbLayer dbLayer = new DbLayer())
            {
                SqlCommand SqlCmd3 = new SqlCommand("spSelectAppointmentReportById");
                SqlCmd3.CommandType = CommandType.StoredProcedure;
                SqlCmd3.Parameters.AddWithValue("@ClientId", objSurveyAppointmentDetail.ClientId);
                SqlCmd3.Parameters.AddWithValue("@ActionBy", objSurveyAppointmentDetail.ActionBy);
                surveyReportDetail           = dbLayer.GetEntityList <BDMAppointmentReportDTO>(SqlCmd3);
                surveyDetail.BDMSurveyReport = surveyReportDetail;
            }
            return(surveyDetail);
        }
Ejemplo n.º 2
0
        public HttpResponseMessage GetBDMAppointmentDetailByClientId(BDMAppointmentGetIdDTO objSurveyAppointmentDetail)
        {
            HttpResponseMessage message;

            try
            {
                // BDMAppointmentDetailDAL dal = new BDMAppointmentDetailDAL();
                var dynObj = new { result = _obj.GetAppointmentDetailByClientId(objSurveyAppointmentDetail) };
                message = Request.CreateResponse(HttpStatusCode.OK, dynObj);
            }
            catch (Exception ex)
            {
                message = Request.CreateResponse(HttpStatusCode.BadRequest, new { msgText = "Something wrong. Try Again!" });

                ErrorLog.CreateErrorMessage(ex, "BDMAppoinmentDetail", "GetBDMAppointmentDetailById");
            }
            return(message);
        }
        public bool InsertBDMAppointmentDetail(BDMAppointmentDetailInsertDTO objAppointmentDetail)
        {
            bool res = false;
            BDMAppointmentGetIdDTO bdm    = new BDMAppointmentGetIdDTO();
            SqlCommand             SqlCmd = new SqlCommand("spInsertBDMAppoinmentDetail");

            SqlCmd.CommandType = CommandType.StoredProcedure;
            SqlCmd.Parameters.AddWithValue("@EmployeeId", objAppointmentDetail.EmployeeId);
            SqlCmd.Parameters.AddWithValue("@ClientName", objAppointmentDetail.ClientName);
            SqlCmd.Parameters.AddWithValue("@ClientAddress", objAppointmentDetail.ClientAddress);
            SqlCmd.Parameters.AddWithValue("@ClientContactNo", objAppointmentDetail.ClientContactNo);
            SqlCmd.Parameters.AddWithValue("@ContactPerson", objAppointmentDetail.ContactPerson);
            SqlCmd.Parameters.AddWithValue("@Designation", objAppointmentDetail.Designation);
            SqlCmd.Parameters.AddWithValue("@Mobile", objAppointmentDetail.Mobile);
            SqlCmd.Parameters.AddWithValue("@Email", objAppointmentDetail.Email);
            SqlCmd.Parameters.AddWithValue("@ReferBy", (objAppointmentDetail.ReferBy == null) ? "" : objAppointmentDetail.ReferBy);
            SqlCmd.Parameters.AddWithValue("@State", objAppointmentDetail.State);
            SqlCmd.Parameters.AddWithValue("@City", objAppointmentDetail.City);
            SqlCmd.Parameters.AddWithValue("@ExistCompetitors", objAppointmentDetail.ExistCompetitors);
            SqlCmd.Parameters.AddWithValue("@CreatedBy", objAppointmentDetail.CreatedBy);
            bdm = _unitOfWork.DbLayer.GetEntityList <BDMAppointmentGetIdDTO>(SqlCmd).FirstOrDefault();
            if (bdm != null)
            {
                SqlCommand sqlCmd1 = new SqlCommand("spInsertRequirementDetails");
                sqlCmd1.CommandType = CommandType.StoredProcedure;
                sqlCmd1.Parameters.AddWithValue("@ClientId", bdm.ClientId);
                sqlCmd1.Parameters.AddWithValue("@CreatedBy", objAppointmentDetail.CreatedBy);
                sqlCmd1.Parameters.Add(new SqlParameter("@Designation", SqlDbType.Int));
                sqlCmd1.Parameters.Add(new SqlParameter("@Service", SqlDbType.Int));
                sqlCmd1.Parameters.Add(new SqlParameter("@RatePerEmployee", SqlDbType.Int));
                sqlCmd1.Parameters.Add(new SqlParameter("@EmployeeCount", SqlDbType.Int));
                foreach (var requirement in objAppointmentDetail.RequirementDetail)
                {
                    if (sqlCmd1.Connection != null)
                    {
                        if (sqlCmd1.Connection.State == ConnectionState.Closed)
                        {
                            sqlCmd1.Connection.Open();
                        }
                    }

                    sqlCmd1.Parameters["@Designation"].Value     = requirement.Designation;
                    sqlCmd1.Parameters["@Service"].Value         = requirement.Service;
                    sqlCmd1.Parameters["@RatePerEmployee"].Value = requirement.RatePerEmployee;
                    sqlCmd1.Parameters["@EmployeeCount"].Value   = requirement.EmployeeCount;
                    int queryRes = _unitOfWork.DbLayer.ExecuteNonQuery(sqlCmd1);
                    if (queryRes != Int32.MaxValue)
                    {
                        res = true;
                    }
                    else
                    {
                        // this part needed error handling code.
                        res = false;
                    }
                }
                if (objAppointmentDetail.ExistCompetitors)
                {
                    SqlCommand sqlCmd2 = new SqlCommand("spInsertCompetitors");
                    sqlCmd2.CommandType = CommandType.StoredProcedure;
                    sqlCmd2.Parameters.AddWithValue("@ClientId", bdm.ClientId);
                    sqlCmd2.Parameters.AddWithValue("@CreatedBy", objAppointmentDetail.CreatedBy);
                    sqlCmd2.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar));
                    sqlCmd2.Parameters.Add(new SqlParameter("@Designation", SqlDbType.VarChar));
                    sqlCmd2.Parameters.Add(new SqlParameter("@Service", SqlDbType.VarChar));
                    sqlCmd2.Parameters.Add(new SqlParameter("@RatePerEmployee", SqlDbType.Int));
                    sqlCmd2.Parameters.Add(new SqlParameter("@EmployeeCount", SqlDbType.Int));
                    foreach (var competitor in objAppointmentDetail.Competitor)
                    {
                        if (sqlCmd2.Connection != null)
                        {
                            if (sqlCmd2.Connection.State == ConnectionState.Closed)
                            {
                                sqlCmd2.Connection.Open();
                            }
                        }
                        sqlCmd2.Parameters["@Name"].Value            = competitor.Name;
                        sqlCmd2.Parameters["@Designation"].Value     = competitor.Designation;
                        sqlCmd2.Parameters["@Service"].Value         = competitor.Service;
                        sqlCmd2.Parameters["@RatePerEmployee"].Value = competitor.RatePerEmployee;
                        sqlCmd2.Parameters["@EmployeeCount"].Value   = competitor.EmployeeCount;
                        int queryRes = _unitOfWork.DbLayer.ExecuteNonQuery(sqlCmd2);
                        if (queryRes != Int32.MaxValue)
                        {
                            res = true;
                        }
                        else
                        {
                            // this part needed error handling code.
                            res = false;
                        }
                    }
                }
                res = true;
            }
            return(res);
        }