Esempio n. 1
0
 public HttpResponseMessage Delete(AgentBusinessModel model)
 {
     try
     {
         if (this.ModelState.IsValid)
         {
             var companyAgentBusinessList = _agentBusinessService.DeleteAgentBusiness(model);
             if (companyAgentBusinessList != null)
             {
                 return(Request.CreateResponse(HttpStatusCode.OK, companyAgentBusinessList));
             }
             else
             {
                 string message = "Not deleted successfully";
                 return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
             }
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
     }
 }
        public List <AgentBusinessModel> GetAllAgentBusinessList(BaseViewModel model)
        {
            List <AgentBusinessModel> agentBusinessList = new List <AgentBusinessModel>();
            AgentBusinessModel        agentBusinessModel;

            try
            {
                _sqlConnService.OpenConnection();
                SqlCommand command = new SqlCommand("SP_GetAllAgentBusiness", _sqlConnService.CreateConnection());
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@CultureId", model.CurrentCulture);
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    agentBusinessModel                = new AgentBusinessModel();
                    agentBusinessModel.ID             = Guid.Parse(reader["ID"].ToString());
                    agentBusinessModel.Code           = reader["Code"].ToString();
                    agentBusinessModel.Name           = reader["Name"].ToString();
                    agentBusinessModel.IsActive       = Convert.ToBoolean(reader["IsActive"].ToString());
                    agentBusinessModel.CreatedDate    = Convert.ToDateTime(reader["CreatedDate"].ToString());
                    agentBusinessModel.CreatedBy      = Convert.ToInt32(reader["CreatedBy"].ToString());
                    agentBusinessModel.UpdatedDate    = Convert.ToDateTime(reader["UpdatedDate"].ToString());
                    agentBusinessModel.UpdatedBy      = Convert.ToInt32(reader["UpdatedBy"].ToString());
                    agentBusinessModel.CurrentUserID  = model.CurrentUserID;
                    agentBusinessModel.CurrentCulture = model.CurrentCulture;
                    agentBusinessList.Add(agentBusinessModel);
                }
                _sqlConnService.CloseConnection();
            }
            catch (Exception ex)
            {
                IErrorLogService errorLog = new ErrorLogService();
                string           message  = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message;
                errorLog.SetErrorLog(model.CurrentUserID, "AgentBusiness", message);
                throw new Exception(ex.Message);
            }
            return(agentBusinessList);
        }
Esempio n. 3
0
        public List <AgentEntity> LoadAgentData()
        {
            AgentBusinessModel agentBusinessModel = new AgentBusinessModel();

            return(agentBusinessModel.LoadAgentData());
        }