//SqlConnection vc_newconn = new SqlConnection(new AdobeConnection().vc_971); #region Read public List <AssetDTO> Show_Asset_List_ByClassCode(string classCode, string term)//oksargolChangeTypeClassCodeok { List <AssetDTO> assetList = new List <AssetDTO>(); SqlCommand cmdAsset = new SqlCommand(); cmdAsset.Connection = conn; cmdAsset.CommandType = CommandType.StoredProcedure; cmdAsset.CommandText = "Adobe.SP_Get_AssetList_ByClassCode"; cmdAsset.Parameters.AddWithValue("@classCode", classCode); cmdAsset.Parameters.AddWithValue("@term", term); conn.Open(); DataTable dt = new DataTable(); SqlDataReader rdr; rdr = cmdAsset.ExecuteReader(); dt.Load(rdr); for (int i = 0; i < dt.Rows.Count; i++) { AssetDTO asset = new AssetDTO(); asset.AssetID = int.Parse(dt.Rows[i]["AssetID"].ToString()); asset.FileName = dt.Rows[i]["FileName"].ToString(); asset.FileDate = dt.Rows[i]["FileDate"].ToString(); asset.Class_Code = (dt.Rows[i]["Class_Code"].ToString()); asset.Term = dt.Rows[i]["Term"].ToString(); assetList.Add(asset); } conn.Close(); return(assetList); }
public List <AssetDTO> GetValidAssets(string stcode)//oksargolChangeTypeClassCode { List <AssetDTO> assetList = new List <AssetDTO>(); SqlCommand cmdAsset = new SqlCommand(); cmdAsset.Connection = conn; cmdAsset.CommandType = CommandType.StoredProcedure; cmdAsset.CommandText = "Adobe.SP_Get_ValidAsset"; cmdAsset.Parameters.AddWithValue("@stcode", stcode); conn.Open(); DataTable dt = new DataTable(); SqlDataReader rdr; rdr = cmdAsset.ExecuteReader(); dt.Load(rdr); for (int i = 0; i < dt.Rows.Count; i++) { AssetDTO asset = new AssetDTO(); asset.AssetID = int.Parse(dt.Rows[i]["AssetID"].ToString()); asset.FileName = dt.Rows[i]["FileName"].ToString(); asset.namedars = dt.Rows[i]["namedars"].ToString(); asset.FileDate = dt.Rows[i]["FileDate"].ToString(); asset.TimeCode = dt.Rows[i]["TimeCode"].ToString(); asset.URL_File = dt.Rows[i]["URL_File"].ToString(); asset.FileDate = dt.Rows[i]["FileDate"].ToString(); asset.Class_Code = (dt.Rows[i]["AssetClassCode"].ToString()); asset.RowId = dt.Rows[i]["RowId"].ToString(); asset.Term = dt.Rows[i]["Term"].ToString(); assetList.Add(asset); } conn.Close(); return(assetList); }
public bool SearchInventory(AssetDTO assetDTO) { var result = from a in db.Asset .Where(a => a.IsDisposed == false && (a.AssetKey.ToString().Contains(assetDTO.AssetTag.ToString()) || a.InventoryOwner.Contains(assetDTO.InventoryOwner)) && (a.ClientSiteKey.Equals(assetDTO.ClientSiteKey) || a.LocationKey.Equals(assetDTO.LocationKey))) orderby a.AssetKey descending select new AssetDTO() { AssetTag = a.AssetKey, Product = a.ProductKeyNavigation.ProductName, Manufacturer = a.ManufacturerKeyNavigation.ManufacturerName, Model = a.ModelKeyNavigation.ModelName, SerialNumber = a.SerialNumber, ItemName = a.ItemName, Location = a.LocationKeyNavigation.LocationName, ClientSite = a.ClientSiteKeyNavigation.ClientSiteName, PurchaseDate = a.PurchaseDate, InventoryOwner = a.InventoryOwner, InventoriedBy = a.InventoriedBy, isDisposed = a.IsDisposed }; if (result.Any()) { return(true); } else { return(false); } }
public void SubmitAsset(AssetDTO assetDTO) { var asset = db.Asset.Single(x => x.AssetKey == assetDTO.AssetTag); asset.InventoryDate = DateTime.Now; db.SaveChanges(); }
public async Task <AssetDTO> CreateTestAsset() { AssetDTO newAssetDTO = this.mapper.Map <AssetDTO>(EnumerableUtils.PickRandom(AllAssetsFromDB)); newAssetDTO.Id += Helpers.Random.Next(1000, 9999).ToString() + GlobalConstants.AutoTest; newAssetDTO.Name += Helpers.Random.Next(1000, 9999).ToString() + GlobalConstants.AutoTest; newAssetDTO.BlockChainAssetId += Helpers.Random.Next(1000, 9999).ToString() + GlobalConstants.AutoTest; newAssetDTO.BlockChainId += Helpers.Random.Next(1000, 9999).ToString() + GlobalConstants.AutoTest; newAssetDTO.Accuracy = Helpers.Random.Next(2, 6); newAssetDTO.MultiplierPower = Helpers.Random.Next(6, 10); string url = ApiPaths.ASSETS_V2_BASE_PATH; string createParam = JsonUtils.SerializeObject(newAssetDTO); var response = await Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, createParam, Method.POST); if (response.Status != HttpStatusCode.Created) { return(null); } AddOneTimeCleanupAction(async() => await DeleteTestAsset(newAssetDTO.Id)); return(newAssetDTO); }
public async Task <Result <ResponseWithElement <bool> > > UpdateAsset(AssetDTO asset) { var errors = new Dictionary <string, List <string> >(); try { var exist = await _unitOfWork.AssetsRepository.ExistAsync(r => r.Id == asset.ID); if (!exist) { _logger.LogError($"Error updating asset with id: {asset.ID}| error: A asset with that id doesn't exist."); errors.Add("$.asset", new List <string> { "The asset doesn't exist." }); return(ResponseHelper.NewResult(HttpStatusCode.BadRequest, ResponseHelper.NewResponseWithElement <bool>(errors: errors))); } var assetToUpdate = _khanMapper.MapToANew <AssetDTO, Asset>(asset); await _unitOfWork.AssetsRepository.UpdateAsync(assetToUpdate); return(ResponseHelper.NewResult(HttpStatusCode.OK, ResponseHelper.NewResponseWithElement(true))); } catch (Exception ex) { _logger.LogError($"Error updating asset with id: {asset.ID}| error: {ex.Message}"); errors.Add("$.asset", new List <string> { ex.Message }); return(ResponseHelper.NewResult(HttpStatusCode.BadRequest, ResponseHelper.NewResponseWithElement <bool>(false, "Update asset", errors))); } }
public async Task <AssetDTO> CreateAsync(AssetDTO asset) { var content = new StringContent(JsonConvert.SerializeObject(asset), Encoding.UTF8, "application/json"); var result = await _httpClient.PostAsync(_url, content); return(JsonConvert.DeserializeObject <AssetDTO>(await result.Content.ReadAsStringAsync())); }
public async Task <Result <ResponseWithElement <string> > > NewAsset(AssetDTO asset) { var errors = new Dictionary <string, List <string> >(); try { var exist = await _unitOfWork.AssetsRepository.ExistAsync(r => r.Id == asset.ID); if (exist) { _logger.LogError($"Error adding new asset | error: A asset with that id exist."); errors.Add("$.asset", new List <string> { "A asset with that id exist." }); return(ResponseHelper.NewResult(HttpStatusCode.BadRequest, ResponseHelper.NewResponseWithElement <string>(errors: errors))); } var newAsset = _khanMapper.MapToANew <AssetDTO, Asset>(asset); await _unitOfWork.AssetsRepository.AddAsync(newAsset); await _unitOfWork.SaveAsync(); //Logger. return(ResponseHelper.NewResult(HttpStatusCode.OK, ResponseHelper.NewResponseWithElement($"{newAsset.Id}"))); } catch (Exception ex) { _logger.LogError($"Error adding new asset | error: {ex.Message}"); errors.Add("$.asset", new List <string> { ex.Message }); return(ResponseHelper.NewResult(HttpStatusCode.BadRequest, ResponseHelper.NewResponseWithElement <string>(null, "Add new asset", errors))); } }
public void GetAllUrlsByTerm(string term, int day, string filedate) { DataTable dt = new DataTable(); DataTable dtClasses = assetDAO.GetAllAssetByTime(filedate); for (int j = 0; j < dtClasses.Rows.Count; j++) { AssetDTO asset = new AssetDTO(); // asset.AssetID = int.Parse(dt.Rows[i]["AssetID"].ToString()); asset.Class_Code = (dtClasses.Rows[j]["code"].ToString()); asset.URL_File = "/" + dtClasses.Rows[j]["_val"].ToString() + "/"; asset.Term = term; asset.Session = dtClasses.Rows[j]["session"].ToString(); asset.Fee = 3000; asset.FileSize = double.Parse(dtClasses.Rows[j]["storage"].ToString()); asset.FileName = dtClasses.Rows[j]["name"].ToString(); asset.FileTime = dtClasses.Rows[j]["DATE_CREATED"].ToString(); asset.FileDate = dtClasses.Rows[j]["Shamsi Date"].ToString(); asset.IsSynch = true; asset.link_view = ""; assetDAO.InsertIntoAssetFromServer(asset); } }
/// <summary> /// Update a Asset /// </summary> /// <param name="assetDTO">The asset to be updated</param> public void Update(AssetDTO assetDTO) { var asset = this.mapper.Map <Asset>(assetDTO); this.assetRepository.Update(asset); this.assetRepository.Save(); }
public async Task <AssetDTO> GetAsssetByName(string name) { Asset asset = await _assetBLL.GetAsssetByName(name); AssetDTO assetDTO = _mapper.Map <AssetDTO>(asset); return(assetDTO); }
public async Task <AssetDTO> GetAssetById(int id) { Asset asset = await _assetBLL.GetAssetById(id); AssetDTO assetDTO = _mapper.Map <AssetDTO>(asset); return(assetDTO); }
public void Add(AssetDTO DTO) { using (var container = new InventoryContainer()) { PayAsset gur = new PayAsset(); container.PayAssets.AddObject((PayAsset)DTOMapper.DTOObjectConverter(DTO, gur)); container.SaveChanges(); } }
public async Task <IActionResult> Post(AssetDTO asset) { asset.CreateBy = await this.HttpContext.LoggedInUser(); asset.CreatedDate = DateTime.UtcNow; var createdAsset = await this.assetService.Create(asset); return(Ok(createdAsset.AssetId)); }
public void Put(AssetDTO asset) { if (!_putValidator.Validate(asset).IsValid) { throw new InvalidOperationException(); } _service.Insert(asset); }
public async Task <ActionResponse <AssetDTO> > SaveAsync(AssetDTO data) { data.AssetType = Types.AssetType.Table; var response = CreateResponse(data); response.Response.Id = await _assetRepository.SaveAsync(Map <Domain.Asset>(data)); return(response); }
/// <summary> /// Create a new Asset /// </summary> /// <param name="assetDTO"></param> /// <returns></returns> public async Task <AssetDTO> Create(AssetDTO assetDTO) { var asset = this.mapper.Map <Asset>(assetDTO); var createdAsset = await this.assetRepository.Create(asset); this.assetRepository.Save(); assetDTO.AssetId = createdAsset.AssetId; return(assetDTO); }
public AssetViewModel(/*IEnumerable<AssetDTO> assetDTOs,*/ List <ClientSiteDTO> clientSiteDTOs, List <LocationDTO> locationDTOs, AssetDTO assetDTO, List <ProductDTO> productDTOs, List <ManufacturerDTO> manufacturerDTOs, List <ModelDTO> modelDTOs) { //AssetDTOs = assetDTOs; ClientSiteDTOs = clientSiteDTOs; LocationDTOs = locationDTOs; AssetDTO = assetDTO; ProductDTOs = productDTOs; ManufacturerDTOs = manufacturerDTOs; ModelDTOs = modelDTOs; }
public HttpResponseMessage CreateAsset([FromBody] AssetDTO assetDTO) { int newID = _assetService.CreateAsset(assetDTO); string uri = Url.Link("AssetByIDRoute", new { id = newID }); // Generate a link to the new campus and set the location header in the response. var response = new HttpResponseMessage(HttpStatusCode.Created); response.Headers.Location = new System.Uri(uri); return(response); }
public AssetDTO CreateAssetDTO() { AssetDTO assetDTO = new AssetDTO() { LocationKey = 1, ClientSiteKey = 1, }; return(assetDTO); }
public async Task CreateAsset() { AssetDTO createdAsset = await this.CreateTestAsset(); Assert.NotNull(createdAsset); AssetEntity entity = await this.AssetRepository.TryGetAsync(createdAsset.Id) as AssetEntity; entity.ShouldBeEquivalentTo(createdAsset, o => o .ExcludingMissingMembers()); }
public void GetAllUrlsByTerm(string term, string filedate, string todate) { DataTable dt = new DataTable(); DataTable dtClasses = assetDAO.GetAllAssetByTime(filedate, todate); for (int j = 0; j < dtClasses.Rows.Count; j++) { try { AssetDTO asset = new AssetDTO(); // asset.AssetID = int.Parse(dt.Rows[i]["AssetID"].ToString()); asset.Class_Code = (dtClasses.Rows[j]["code"].ToString()); asset.URL_File = "/" + dtClasses.Rows[j]["_val"].ToString() + "/"; asset.Term = term; asset.Session = dtClasses.Rows[j]["session"].ToString(); switch (term) { case "94-95-1": case "94-95-2": case "95-96-1": case "95-96-2": asset.Fee = 3000; break; case "96-97-1": case "96-97-2": case "97-98-1": case "97-98-2": asset.Fee = 5000; break; default: asset.Fee = 10000; break; } asset.FileSize = double.Parse(dtClasses.Rows[j]["storage"].ToString()); asset.FileName = dtClasses.Rows[j]["name"].ToString(); asset.FileTime = dtClasses.Rows[j]["DATE_CREATED"].ToString(); asset.FileDate = dtClasses.Rows[j]["Shamsi Date"].ToString(); asset.IsSynch = true; asset.link_view = ""; asset.scoid = long.Parse(dtClasses.Rows[j]["scoid"].ToString()); assetDAO.InsertIntoAssetFromServer(asset); } catch (Exception ex) { } } }
public ActionResult SearchInventory(AssetDTO assetDTO) { var wasInventoryFound = _service.SearchInventory(assetDTO); if (wasInventoryFound.Equals(true)) { return(PartialView("_ItemFound")); } else { return(PartialView("_ItemNotFound")); } }
public async Task <IActionResult> AddAsset(AssetDTO assetDTO) { bool success = false; try { success = await _assetFacade.AddAsset(assetDTO); } catch (Exception ex) { throw ex; } return(base.Ok(success)); }
public ActionResult AddItem(AssetDTO assetDTO) { var doesAssetAlreadyExist = _service.SearchInventory(assetDTO); if (doesAssetAlreadyExist) { return(Json(new { success = false, responseText = "This Asset Already Exists. Please Try Again" })); } else { _service.CreateAsset(assetDTO); return(Json(new { success = true, responseText = "The Asset Was Added" })); } }
public async Task GetSingleAsset() { string url = ApiPaths.ASSETS_BASE_PATH + "/" + this.TestAsset.Id; var response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, null, Method.GET); Assert.True(response.Status == HttpStatusCode.OK); Assert.NotNull(response.ResponseJson); AssetDTO parsedResponse = JsonUtils.DeserializeJson <AssetDTO>(response.ResponseJson); this.TestAsset.ShouldBeEquivalentTo(parsedResponse, options => options .ExcludingMissingMembers() .Excluding(a => a.PartnerIds)); }
//[Fact] public async Task Should_Return_OK_When_PostAsync() { HttpClientFactory client = new HttpClientFactory(MockStartup <Startup> .Instance.GetCliente()); await client.AddAuthorizationAsync(); var entity = new AssetDTO() { Name = "Teste", Description = "teste", Symbol = "T" }; var result = await client.PostAsync(ROUTE_PATH, entity); Assert.Equal(HttpStatusCode.OK, result.StatusCode); }
public async Task DeleteAsset() { AssetDTO TestAssetDelete = await CreateTestAsset(); string url = ApiPaths.ASSETS_V2_BASE_PATH + "/" + TestAssetDelete.Id; string deleteParam = JsonUtils.SerializeObject(new { id = TestAssetDelete.Id }); var deleteResponse = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, deleteParam, Method.DELETE); Assert.True(deleteResponse.Status == HttpStatusCode.NoContent); AssetEntity entityDeleted = await this.AssetRepository.TryGetAsync(TestAssetDelete.Id) as AssetEntity; Assert.Null(entityDeleted); }
public async Task <IActionResult> CreateAsync([FromBody] AssetDTO newAsset) { if (await _dbContext.Assets.AnyAsync(x => x.Id == newAsset.Id)) { return(BadRequest()); } _dbContext.Assets.Add(new Asset() { Name = newAsset.Name, CreatedBy = new Guid() }); _dbContext.SaveChanges(); return(Ok(newAsset)); }
public void Edit(AssetDTO EduDTO) { using (var container = new InventoryContainer()) { var Comp = new PayAsset(); Comp = container.PayAssets.FirstOrDefault(o => o.AssetId.Equals(EduDTO.AssetId)); Comp.BankAmount_Current = EduDTO.BankAmount_Current; Comp.CashAmount_Current = EduDTO.CashAmount_Current; Comp = (PayAsset)DTOMapper.DTOObjectConverter(EduDTO, Comp); container.SaveChanges(); } }
private AssetDTO Map(tblAsset tbl) { var dto = new AssetDTO { MasterId = tbl.Id, DateCreated = tbl.IM_DateCreated, DateLastUpdated = tbl.IM_DateLastUpdated, StatusId = tbl.IM_Status, AssetNo = tbl.AssetNo, AssetCategoryMasterId = tbl.AssetCategoryId ?? Guid.Empty, AssetStatusMasterId = tbl.AssetStatusId ?? Guid.Empty, AssetTypeMasterId = tbl.AssetTypeId, Name = tbl.Name, Capacity = tbl.Capacity, Code = tbl.Code, SerialNo = tbl.SerialNo }; return dto; }
public Asset Map(AssetDTO dto) { if (dto == null) return null; var asset = Mapper.Map<AssetDTO, Asset>(dto); asset.AssetCategory = _assetCategoryRepository.GetById(dto.AssetCategoryMasterId); asset.AssetStatus = _assetStatusRepository.GetById(dto.AssetStatusMasterId); asset.AssetType = _assetTypeRepository.GetById(dto.AssetTypeMasterId); return asset; }