Example #1
0
        protected void btnSaveAssetCategory_Click(object sender, EventArgs e)
        {
            AssetCategoryEntity ace = new AssetCategoryEntity();

            ace.Name         = txtAssetCategoryName.Text.Trim();
            ace.Description  = txtAssetCategoryDescription.Text.Trim().Length > 0 ? txtAssetCategoryDescription.Text.Trim() : null;
            ace.SpanishLabel = txtAssetCategorySpanishLabel.Text.Trim().Length > 0 ? txtAssetCategorySpanishLabel.Text.Trim() : null;
            ace.Save();

            txtAssetCategoryName.Text         = "";
            txtAssetCategoryDescription.Text  = "";
            txtAssetCategorySpanishLabel.Text = "";

            var assetCategories = from ac in _db.AssetCategory
                                  orderby ac.Name
                                  select ac;

            ddlAssetCategory.Items.Clear();

            foreach (AssetCategoryEntity ac in assetCategories)
            {
                ListItem li = new ListItem(ac.Name, ac.AssetCategoryId.ToString());
                ddlAssetCategory.Items.Add(li);
            }

            txtAssetCategoryName.Focus();
            rdAssetTypeGrid.Rebind();
        }
Example #2
0
        public async Task UpdateAssetCategory()
        {
            string url = ApiPaths.ASSET_CATEGORIES_PATH;

            AssetCategoryDTO TestAssetCategoryUpdate = await CreateTestAssetCategory();

            AssetCategoryDTO updateCategory = new AssetCategoryDTO()
            {
                Id             = TestAssetCategoryUpdate.Id,
                Name           = TestAssetCategoryUpdate.Name,
                AndroidIconUrl = TestAssetCategoryUpdate.AndroidIconUrl + "_autotest",
                IosIconUrl     = TestAssetCategoryUpdate.IosIconUrl,
                SortOrder      = TestAssetCategoryUpdate.SortOrder
            };
            string updateParam = JsonUtils.SerializeObject(updateCategory);

            var updateResponse = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, updateParam, Method.PUT);

            Assert.True(updateResponse.Status == HttpStatusCode.NoContent);

            AssetCategoryEntity checkDbUpdated = (AssetCategoryEntity)await this.AssetCategoryManager.TryGetAsync(TestAssetCategoryUpdate.Id);

            checkDbUpdated.ShouldBeEquivalentTo(updateCategory, o => o
                                                .ExcludingMissingMembers());
        }
Example #3
0
        public async Task CreateAssetCategory()
        {
            AssetCategoryDTO createdCategory = await this.CreateTestAssetCategory();

            Assert.NotNull(createdCategory);

            AssetCategoryEntity checkDbCreated = (AssetCategoryEntity)await this.AssetCategoryManager.TryGetAsync(createdCategory.Id);

            checkDbCreated.ShouldBeEquivalentTo(createdCategory, o => o
                                                .ExcludingMissingMembers());
        }
Example #4
0
        public async Task DeleteAssetCategory()
        {
            AssetCategoryDTO TestAssetCategoryDelete = await CreateTestAssetCategory();

            string url            = ApiPaths.ASSET_CATEGORIES_PATH + "/" + TestAssetCategoryDelete.Id;
            var    deleteResponse = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, null, Method.DELETE);

            Assert.True(deleteResponse.Status == HttpStatusCode.NoContent);

            AssetCategoryEntity checkDbDeleted = (AssetCategoryEntity)await this.AssetCategoryManager.TryGetAsync(TestAssetCategoryDelete.Id);

            Assert.Null(checkDbDeleted);
        }
Example #5
0
        protected void rdAssetTypeGrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
        {
            if (_assetReclamationServiceLocation != null)
            {
                GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
                Hashtable    values   = new Hashtable();
                dataItem.ExtractValues(values);

                int assetCategoryId = Convert.ToInt32(values["AssetCategoryId"].ToString());
                AssetCategoryEntity assetCategory = new AssetCategoryEntity(assetCategoryId);

                var assetTypes = from at in _db.AssetType
                                 where at.AssetCategoryId == assetCategory.AssetCategoryId
                                 orderby at.Name
                                 select at;

                var serviceLocationAssetTypes = from slat in _db.ServiceLocationAssetType
                                                join at in _db.AssetType on slat.AssetTypeId equals at.AssetTypeId
                                                join ac in _db.AssetCategory on at.AssetCategoryId equals ac.AssetCategoryId
                                                where at.AssetCategoryId == assetCategory.AssetCategoryId &&
                                                slat.ServiceLocationId == _assetReclamationServiceLocation.ServiceLocationId
                                                select slat;

                List <ServiceLocationAssetTypeEntity> slats = new List <ServiceLocationAssetTypeEntity>();

                foreach (AssetTypeEntity ate in assetTypes)
                {
                    if (serviceLocationAssetTypes.Where(x => x.AssetTypeId == ate.AssetTypeId).Count() > 0)
                    {
                        slats.Add(serviceLocationAssetTypes.Where(x => x.AssetTypeId == ate.AssetTypeId).First());
                    }
                    else
                    {
                        ServiceLocationAssetTypeEntity slat = new ServiceLocationAssetTypeEntity();
                        slat.ServiceLocationId = _assetReclamationServiceLocation.ServiceLocationId;
                        slat.AssetTypeId       = ate.AssetTypeId;
                        slat.PricePerUnit      = 0;
                        slat.Save();
                        slats.Add(slat);
                    }
                }

                e.DetailTableView.DataSource = slats.OrderBy(x => x.AssetType.Name);
            }
            else
            {
                e.DetailTableView.DataSource = null;
            }
        }
Example #6
0
        protected void rdAssetTypeGrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
        {
            GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
            Hashtable    values   = new Hashtable();

            dataItem.ExtractValues(values);

            int assetCategoryId = Convert.ToInt32(values["AssetCategoryId"].ToString());
            AssetCategoryEntity assetCategory = new AssetCategoryEntity(assetCategoryId);

            var assetTypes = from at in _db.AssetType
                             where at.AssetCategoryId == assetCategory.AssetCategoryId
                             orderby at.Name
                             select at;

            e.DetailTableView.DataSource = assetTypes;
        }
Example #7
0
        public async Task GetSingleAssetCategory()
        {
            string url      = ApiPaths.ASSET_CATEGORIES_PATH + "/" + this.TestAssetCategory.Id;
            var    response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, null, Method.GET);

            Assert.True(response.Status == HttpStatusCode.OK);
            Assert.NotNull(response.ResponseJson);

            AssetCategoryDTO parsedResponse = JsonUtils.DeserializeJson <AssetCategoryDTO>(response.ResponseJson);

            AssetCategoryEntity entity = (AssetCategoryEntity)await this.AssetCategoryManager.TryGetAsync(this.TestAssetCategory.Id);

            Assert.NotNull(entity);

            entity.ShouldBeEquivalentTo(parsedResponse, o => o
                                        .ExcludingMissingMembers());
        }