예제 #1
0
        public IActionResult get()
        {
            using (var db = new StepperTaskDBContext())
            {
                List <Steps>   steps  = db.Steps.Include(step => step.Items).ToList();
                List <StepDTO> result = ConfigMapper.MapList <Steps, StepDTO>(steps);

                return(Ok(result));
            }
        }
        public override ResponseBase ExecuteRequest()
        {
            List <CustomerDTO>  CustomerDTOs   = new List <CustomerDTO>();
            GetCustomerResponse responseObject = new GetCustomerResponse();

            try
            {
                List <Customer> CUSTOMERs = new List <Customer>();

                using (CustomerDemoEntities ctx = new CustomerDemoEntities())
                {
                    if (!String.IsNullOrEmpty(SearchKey))
                    {
                        CUSTOMERs = ctx.Customers.Where(c => c.Name.Contains(SearchKey) ||
                                                        c.Email.Contains(SearchKey)).ToList();
                        // || (c.ID = ctx.PhoneNumbers.Where(p => p.Number.ToString().Contains(SearchKey)).FirstOrDefault().ID).ToList();


                        CustomerDTOs = ConfigMapper.MapList <Customer, CustomerDTO>(CUSTOMERs);
                        if (CustomerDTOs.Count == 0)
                        {
                            responseObject.Message = "No Customer found";
                        }
                        responseObject.IsSuccess = true;
                        responseObject.customers = CustomerDTOs;
                    }
                    else
                    {
                        CUSTOMERs = ctx.Customers.ToList();

                        if (CUSTOMERs.Count > 0)
                        {
                            CustomerDTOs = ConfigMapper.MapList <Customer, CustomerDTO>(CUSTOMERs);

                            responseObject.IsSuccess = true;
                            responseObject.customers = CustomerDTOs;
                        }
                        else
                        {
                            responseObject.Message   = "No Customer found";
                            responseObject.IsSuccess = true;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                responseObject.IsSuccess = false;
                responseObject.Message   = e.Message;
            }

            return(responseObject);
        }
        public IHttpActionResult GetRecurringCostType()
        {
            try
            {
                List <RecurringType> recurringCostTypeList = db.RecurringTypes.ToList();

                if (recurringCostTypeList.Count > 0)
                {
                    List <RecurringCostTypeDTO> result = ConfigMapper.MapList <RecurringType, RecurringCostTypeDTO>(recurringCostTypeList);

                    return(Ok(result));
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                return(BadRequest());
            }
        }
        public IHttpActionResult GetBudgetType()
        {
            try
            {
                List <BudgetType> budgetTypesList = db.BudgetTypes.ToList();

                if (budgetTypesList.Count > 0)
                {
                    List <BudgetTypeDTO> result = ConfigMapper.MapList <BudgetType, BudgetTypeDTO>(budgetTypesList);

                    return(Ok(result));
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception e)
            {
                return(BadRequest());
            }
        }