コード例 #1
0
        public void loadForm()
        {
            ClearFields();
            firstLoad = true;
            using (var db = new WTCCeresEntities())
            {
                {
                    var withBlock = cboRateTier;
                    withBlock.DataSource    = CompanyRateTypeService.GetAllCustomerRateType(db);
                    withBlock.DisplayMember = "RateCode";
                    withBlock.ValueMember   = "CustomerRateTypeId";
                }

                cblCompanyType.DataSource = null;
                {
                    var withBlock1 = cblCompanyType;
                    withBlock1.DataSource    = CompanyTypeService.GetAll(db);
                    withBlock1.DisplayMember = "DescCompanyType";
                    withBlock1.ValueMember   = "CompanyTypeId";
                }

                {
                    var withBlock2 = cboCompanyCategory;
                    withBlock2.DataSource    = CompanyCategoryService.GetAll(db);
                    withBlock2.DisplayMember = "Category";
                    withBlock2.ValueMember   = "CompanyCategoryId";
                }

                cboRateTier.SelectedValue = 0;
            }

            cboCompanyCategory.SelectedValue = 1;
            isCustomer = true;
            firstLoad  = false;
        }
コード例 #2
0
        // GET api/<controller>
        public IHttpActionResult Get()
        {
            IHttpActionResult             result            = null;
            CompanyCategoryService        service           = new CompanyCategoryService();
            IEnumerable <CompanyCategory> companyCategories = service.GetCompanyCategories();

            if (companyCategories.Count() > 0)
            {
                result = Ok(companyCategories);
            }
            else
            {
                result = NotFound();
            }
            return(result);
        }
コード例 #3
0
        // PUT api/<controller>/5
        public IHttpActionResult Put(CompanyCategory companyCategory)
        {
            IHttpActionResult      result  = null;
            CompanyCategoryService service = new CompanyCategoryService();

            if (service.GetCompanyCategory(companyCategory.ID) != null)
            {
                service.UpdateCompanyCategory(companyCategory);
                result = Ok(companyCategory);
            }
            else
            {
                result = NotFound();
            }

            return(result);
        }
コード例 #4
0
        // POST api/<controller>
        public IHttpActionResult Post(CompanyCategory companyCategory)
        {
            IHttpActionResult      result             = null;
            CompanyCategoryService service            = new CompanyCategoryService();
            CompanyCategory        newCompanyCategory = service.InsertCompanyCategory(companyCategory);

            if (newCompanyCategory != null)
            {
                result = Created <CompanyCategory>(Request.RequestUri + newCompanyCategory.ID.ToString(), newCompanyCategory);
            }
            else
            {
                result = NotFound();
            }

            return(result);
        }
コード例 #5
0
        // GET api/<controller>/5
        public IHttpActionResult Get(int id)
        {
            IHttpActionResult result = null;

            CompanyCategoryService service = new CompanyCategoryService();

            CompanyCategory companyCategory = service.GetCompanyCategory(id);

            if (companyCategory != null)
            {
                result = Ok(companyCategory);
            }
            else
            {
                result = NotFound();
            }

            return(result);
        }
コード例 #6
0
        // DELETE api/<controller>/5
        public IHttpActionResult Delete(int id)
        {
            IHttpActionResult      result  = null;
            CompanyCategoryService service = new CompanyCategoryService();

            CompanyCategory companyCategory = service.GetCompanyCategory(id);

            if (companyCategory != null)
            {
                service.RemoveCompanyCategory(id);

                result = Ok(true);
            }
            else
            {
                result = NotFound();
            }

            return(result);
        }