예제 #1
0
        public IEnumerable <CustomerGetDTO> GetAll()
        {
            IQueryable <Customer> result = context.Customers;

            //return result.Select(c => new CustomerGetDTO {
            //    Name = c.Name,
            //    PhoneNumber = c.PhoneNumber,
            //    Email = c.Email
            //}
            return(result.Select(c => CustomerGetDTO.FromCustomer(c)));
        }
예제 #2
0
        public List <CustomerDTO> GetAllCustomers(CustomerGetDTO objCustomer)
        {
            List <CustomerDTO> customer = new List <CustomerDTO>();


            SqlCommand SqlCmd = new SqlCommand("spSelectCustomer");

            SqlCmd.CommandType = CommandType.StoredProcedure;
            SqlCmd.Parameters.AddWithValue("@ActionBy", objCustomer.ActionBy);
            customer = _unitOfWork.DbLayer.GetEntityList <CustomerDTO>(SqlCmd);

            return(customer);
        }
예제 #3
0
        public CustomerDTO GetCustomerById(CustomerGetDTO objCustomer)
        {
            CustomerDTO customer = new CustomerDTO();


            SqlCommand SqlCmd = new SqlCommand("spSelectCustomer");

            SqlCmd.CommandType = CommandType.StoredProcedure;
            SqlCmd.Parameters.AddWithValue("@Id", objCustomer.Id);
            SqlCmd.Parameters.AddWithValue("@ActionBy", objCustomer.ActionBy);
            customer = _unitOfWork.DbLayer.GetEntityList <CustomerDTO>(SqlCmd).FirstOrDefault();

            return(customer);
        }
        public HttpResponseMessage GetCustomerById(CustomerGetDTO objCustomer)
        {
            HttpResponseMessage message;

            try
            {
                //  CustomerDataAccessLayer dal = new CustomerDataAccessLayer();
                var dynObj = new { result = _Customer.GetCustomerById(objCustomer) };
                message = Request.CreateResponse(HttpStatusCode.OK, dynObj);
            }
            catch (Exception ex)
            {
                message = Request.CreateResponse(HttpStatusCode.BadRequest, new { msgText = "Somthing wrong, Try Again!" });
                ErrorLog.CreateErrorMessage(ex, "Customer", "GetCustomerById");
            }
            return(message);
        }