public GetLongIdResponse DoesContainerExist(ContainerDTO container) { GetLongIdResponse response = new GetLongIdResponse(); response.returnedId = inventoryManager.DoesContainerExist(container); return(response); }
private List <ContainerDTO> ConvertToList(HardwareTree tree, Guid?parentId) { logger.Trace($"Entering {new StackTrace().GetFrame(0).GetMethod().Name}"); logger.Debug($"Parent id = '{parentId}'"); List <ContainerDTO> containers = new List <ContainerDTO>(); var container = new ContainerDTO() { DeviceName = tree.DeviceName, ContainerId = Guid.NewGuid(), ParentId = parentId, Sensors = tree.Sensors }; containers.Add(container); logger.Info($"Adding container '{container.ContainerId}' to list"); logger.Debug($"\twith sensors '{string.Join(",", container.Sensors.Select(s => s.Id))}'"); foreach (var subhardware in tree.Subhardware) { containers.AddRange(ConvertToList(subhardware, container.ContainerId)); } logger.Trace($"Exiting {new StackTrace().GetFrame(0).GetMethod().Name}"); return(containers); }
public JsonResult List() { ContainerDTO <ProductDTO> productContainerDto = productServiceClient.findAllPaged(0, 100); //TODO; implement paging List <ProductModel> data = productContainerDto.list.Select(productDto => MVCModelToDTOUtil.ToProductModelMap(productDto)).ToList(); return(Json(data, JsonRequestBehavior.AllowGet)); }
public ActionResult CreateContainer(CreateContainerVM item) { if (ModelState.IsValid) { ProductDTO product = new ProductDTO() { Name = item.Name, Description = item.Description, Price = item.Price, Sale = item.Sale }; ContainerDTO container = new ContainerDTO(); if (item.Images != null) { foreach (var i in item.Images) { ImageDTO image = new ImageDTO(); image.Text = item.Alt; using (var reader = new BinaryReader(i.InputStream)) image.Photo = reader.ReadBytes(i.ContentLength); product.Images = new List <ImageDTO>(); product.Images.Add(image); } } else { product.Images = new List <ImageDTO>(); foreach (var i in item.ImagesInDatebase) { product.Images.Add(_mappers.ToImageDTO.Map <ImageDM, ImageDTO>(i)); } } container.Products = new List <ProductDTO>(); foreach (var i in item.SelectedProducts) { container.Products.Add(new ProductDTO() { Name = i }); } container.ChanseForLegendary = item.ChanseForLegendary; container.ChanseForRare = item.ChanseForRare; container.MaxRare = item.MaxRare; container.MinRare = item.MinRare; container.Name = item.Name; container.Type = item.Type; container.TypeOfHard = item.TypeOfHard; container.Properties = _mappers.ToPropertyDTO.Map <ICollection <PropertyDM>, ICollection <PropertyDTO> >(item.Properties); OperationDetails result = _adminService.CreateContainer(product, container, product.Name); ViewBag.Result = result.Message; ViewBag.Status = result.Succedeed; List <ProductDM> products = _mappers.ToProductDM.Map <ICollection <ProductDTO>, List <ProductDM> >(_adminService.GetAllProducts()); var prods = products.Select(x => new SelectListItem() { Text = x.Name + " | " + (x.Sale != 0 ? (x.Price - (x.Price * x.Sale) / 100) : x.Price) + " | " + x.Table.ToString() , Value = x.Name }).ToList(); item.Products = prods; return(View(item)); } return(View(item)); }
private void initNameControl(ContainerDTO dto) { var isInit = dto.Name.IsNullOrEmpty(); editNameButton.Enabled = !isInit; editNameButton.Visible = !isInit && !_readOnly; btName.Properties.ReadOnly = !isInit; }
public JsonResult GetDataTable(jQueryDataTableParamModel param) { ContainerDTO <ProductDTO> productContainerDto = productServiceClient.findAllPaged(param.start, param.length); List <ProductModel> data = productContainerDto.list.Select(productDto => MVCModelToDTOUtil.ToProductModelMap(productDto)).ToList(); jQueryDataTableData <ProductModel> dataTableResponse = new jQueryDataTableData <ProductModel>(param.draw, productContainerDto.total, data); return(Json(dataTableResponse, JsonRequestBehavior.AllowGet)); }
protected async Task <PayloadDTO> ExtractContainerPayload(ContainerDTO container) { var payload = await HttpGetAsync <PayloadDTO>( _baseUrl + "containers/payload?id=" + container.Id ); return(payload); }
public IActionResult GetDataTable([FromQuery] jQueryDataTableParamModel param) { ContainerDTO <ProductDTO> productContainerDto = productServiceClient.findAllPagedAsync(param.start, param.length).GetAwaiter().GetResult(); List <ProductModel> data = productContainerDto.list.Select(productDto => MVCModelToDTOUtil.ToProductModelMap(productDto)).ToList(); jQueryDataTableData <ProductModel> dataTableResponse = new jQueryDataTableData <ProductModel>(param.draw, productContainerDto.total, data); return(Ok(dataTableResponse)); }
public AddContainerRequest() { Inventory = new InventoryDTO(); Container = new ContainerDTO(); ServiceCode = new ServiceCodeDTO(); }
public static ContainerDTO TestContainer() { var containerDO = new ContainerDTO(); containerDO.Id = TestContainerGuid(); containerDO.State = 1; return(containerDO); }
public override void Edit(IContainer container, IEnumerable <IObjectBase> existingObjectsInParent) { _container = container; _containerDTO = _containerToDTOContainerMapper.MapFrom(_container); _containerDTO.AddUsedNames(_editTasks.GetForbiddenNamesWithoutSelf(container, existingObjectsInParent)); _editParametersInContainerPresenter.Edit(_container); _view.BindTo(_containerDTO); _view.ContainerPropertiesEditable = !container.IsMoleculeProperties(); }
public Task <Response <ContainerDTO> > CreateContainerAsync([Body] ContainerDTO container) { container.Id = Guid.NewGuid().ToString("D"); this._seedData.Containers.Add(container); var apiResponse = new Response <ContainerDTO>("TestContent", new HttpResponseMessage(System.Net.HttpStatusCode.OK), () => container); return(Task.FromResult(apiResponse)); }
static async Task <ContainerDTO> GetProductAsync2(string path) { ContainerDTO ObjContainerDTO = null; HttpResponseMessage response = await client.GetAsync(path); if (response.IsSuccessStatusCode) { ObjContainerDTO = await response.Content.ReadAsAsync <ContainerDTO>(); } return(ObjContainerDTO); }
static async Task RunAsync3() { // Update port # in the following line. client.BaseAddress = new Uri("http://2.235.241.7:8080/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); try { //// Create a new product //Product product = new Product //{ // Name = "Gizmo", // Price = 100, // Category = "Widgets" //}; //var url = await CreateProductAsync(product); //Console.WriteLine($"Created at {url}"); // var url = "api/products"; // Get the product ContainerDTO ObjContainerDTO = new ContainerDTO(); List <Evento> LstEvento = new List <Evento>(); LstEvento = await GetEventAsync3("events?startDate=2018-08-01&endDate=2018-09-10"); //ShowProduct(product); //// Update the product //Console.WriteLine("Updating price..."); //product.Price = 80; //await UpdateProductAsync(product); //// Get the updated product //product = await GetProductAsync(url.PathAndQuery); //ShowProduct(product); //// Delete the product //var statusCode = await DeleteProductAsync(product.Id); //Console.WriteLine($"Deleted (HTTP Status = {(int)statusCode})"); foreach (Evento Evt in LstEvento) { Console.WriteLine(Evt.description + " " + Evt.amount); } } catch (Exception e) { Console.WriteLine(e.Message); } Console.ReadLine(); }
public void Initialization() { var item = new ContainerDTO { isUsed = new List <string>(), newContainers = new List <string>() { "Container A", "Container B", "Container C", "Container D", "Container E" } }; var containerJson = JsonConvert.SerializeObject(item); System.IO.File.WriteAllText(containerPath, containerJson); }
public OperationDetails CreateContainer(ProductDTO product, ContainerDTO item, string oldContainer) { Product productInDB = Database.Products.Find(p => p.Name == oldContainer).FirstOrDefault(); if (productInDB != null) { return(UpdateContainer(product, item, oldContainer)); } if (item == null || product == null) { return(new OperationDetails(false, "ОбЪект ссылается на null", this.ToString())); } Container container = _mappers.ToContainer.Map <ContainerDTO, Container>(item); container.Name = product.Name; List <Product> products = new List <Product>(); foreach (var pr in item.Products) { Product prod = Database.Products.Find(p => p.Name == pr.Name).FirstOrDefault(); if (prod == null) { return(new OperationDetails(false, "Не удалось найти продукт", this.ToString())); } products.Add(prod); } container.Products = products; Database.Containers.Add(container); Database.Save(); Product localProduct = _mappers.ToProduct.Map <ProductDTO, Product>(product); if (localProduct == null) { return(new OperationDetails(false, "Не удалось преобразовать объект", this.ToString())); } localProduct = CreateProduct(localProduct); localProduct.Table = Goods.Container; Container conainerInDB = Database.Containers.Find(x => x.Name == localProduct.Name).FirstOrDefault(); if (conainerInDB == null) { return(new OperationDetails(false, "Не удалось найти объект", this.ToString())); } localProduct.FromTableId = conainerInDB.Id; Database.Products.Add(localProduct); Database.Save(); return(new OperationDetails(true, "Контейнер был успешно добавлен", this.ToString())); }
static async Task RunAsync2() { // Update port # in the following line. client.BaseAddress = new Uri("http://localhost:50692/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); try { //// Create a new product //Product product = new Product //{ // Name = "Gizmo", // Price = 100, // Category = "Widgets" //}; //var url = await CreateProductAsync(product); //Console.WriteLine($"Created at {url}"); // var url = "api/products"; // Get the product ContainerDTO ObjContainerDTO = new ContainerDTO(); ObjContainerDTO = await GetProductAsync2("api/Utenti/GetUser?IdUser=36"); //ShowProduct(product); //// Update the product //Console.WriteLine("Updating price..."); //product.Price = 80; //await UpdateProductAsync(product); //// Get the updated product //product = await GetProductAsync(url.PathAndQuery); //ShowProduct(product); //// Delete the product //var statusCode = await DeleteProductAsync(product.Id); //Console.WriteLine($"Deleted (HTTP Status = {(int)statusCode})"); } catch (Exception e) { Console.WriteLine(e.Message); } Console.ReadLine(); }
public System.Web.Http.Results.JsonResult <ContainerDTO> GetAudit(LuisEntityAuditDTO ObjLuisEntityAuditDTO) { ContentRepositoryPageManager _MngContentRepositoryPageManager = new ContentRepositoryPageManager(); ContainerDTO ObjContainerDTO = new ContainerDTO(); try { ObjContainerDTO = _MngContentRepositoryPageManager.GetAudit(ObjLuisEntityAuditDTO); ObjContainerDTO.success = true; } catch (Exception ex) { ObjContainerDTO.success = false; ObjContainerDTO.msg = ex.Message; } return(Json(ObjContainerDTO)); }
public virtual async Task RenameAsync(string newName, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var containerDto = new ContainerDTO() { Id = Id, Name = newName }; var serviceResponse = await _containersApi.UpdateContainerAsync(containerDto); if (false == serviceResponse.ResponseMessage.IsSuccessStatusCode) { throw ExceptionGenerator.GeneralFailureException(serviceResponse.StringContent?.ToString()); } var updatedContainer = serviceResponse.GetContent(); this.Id = updatedContainer.Id; this.Name = updatedContainer.Name; }
public Task <Response <ContainerDTO> > UpdateContainerAsync([Body] ContainerDTO container) { var targetContainer = _seedData.Containers.Where(c => c.Id == container.Id).FirstOrDefault(); Response <ContainerDTO> response = null; if (targetContainer != null) { targetContainer.Name = container.Name; response = new Response <ContainerDTO>("Test", new HttpResponseMessage(HttpStatusCode.OK), () => targetContainer); } else { response = new Response <ContainerDTO>("Test", new HttpResponseMessage(HttpStatusCode.NotFound), () => new ContainerDTO()); } return(Task.FromResult(response)); }
public OperationDetails UpdateContainer(ProductDTO product, ContainerDTO item, string oldContainerName) { if (product == null || item == null) { return(new OperationDetails(false, "ОбЪект ссылается на null", this.ToString())); } Product localProduct = UpdateProduct(product); Database.Products.Update(localProduct); Container oldContainer = Database.Containers.Find(x => x.Name == oldContainerName).FirstOrDefault(); if (oldContainer == null) { return(new OperationDetails(false, "Не удалось найти объект", this.ToString())); } List <Product> products = new List <Product>(); foreach (var pr in item.Products) { Product prod = Database.Products.Find(p => p.Name == pr.Name).FirstOrDefault(); if (prod == null) { return(new OperationDetails(false, "Не удалось найти продукт", this.ToString())); } products.Add(prod); } oldContainer.Products = products; oldContainer.ChanseForLegendary = item.ChanseForLegendary; oldContainer.ChanseForRare = item.ChanseForRare; oldContainer.Type = item.Type; oldContainer.Properties = _mappers.ToProperty.Map <IEnumerable <PropertyDTO>, ICollection <Property> >(item.Properties); Database.Containers.Update(oldContainer); Database.Save(); return(new OperationDetails(true, "Компьютерный компонент успешно изменён", this.ToString())); }
public long DoesContainerExist(ContainerDTO containerDTO) { return(persistence.ContainerExists(containerDTO)); }
private void ImportContainer(KeyValuePair <int, List <ExcelRowData> > kvp, ExcelPicture img) { //check for presence of plantName - add if not present long containerNameId = 0; int column = columnIndicesAndNames.Where(a => a.Value == "CONTAINER NAME").Select(b => b.Key).First(); string containerName = rowData[kvp.Key].Where(a => a.column == column).Select(b => b.data).FirstOrDefault() as string; string result = Get("DoesContainerNameExist", "containerName=" + containerName); GetLongIdResponse r = JsonConvert.DeserializeObject <GetLongIdResponse>(result); containerNameId = r.returnedId; //check for presence of plantType - add if not present column = columnIndicesAndNames.Where(a => a.Value.ToUpper() == "SIZE").Select(b => b.Key).First(); string containerSize = rowData[kvp.Key].Where(a => a.column == column).Select(b => b.data).FirstOrDefault() as string; long containerTypeId = 0; column = columnIndicesAndNames.Where(a => a.Value == "TYPE").Select(b => b.Key).First(); string containerType = rowData[kvp.Key].Where(a => a.column == column).Select(b => b.data).FirstOrDefault() as string; result = Get("DoesContainerTypeExist", "containerType=" + containerType); r = JsonConvert.DeserializeObject <GetLongIdResponse>(result); containerTypeId = r.returnedId; ////using cost, retail, plantName and plant Type, check for presence of service code - add if not present //ServiceCodeDTO serviceCode = GetServiceCodeDTO(kvp); //string jsonData = JsonConvert.SerializeObject(serviceCode); //var content = new StringContent(jsonData, Encoding.UTF8, "application/json"); //result = Post("DoesServiceCodeExist", content); long serviceCodeId = 0; column = columnIndicesAndNames.Where(a => a.Value == "CODE").Select(b => b.Key).First(); string serviceCode = rowData[kvp.Key].Where(a => a.column == column).Select(b => b.data).FirstOrDefault() as string; result = Get("ServiceCodeIsNotUnique", "serviceCode=" + serviceCode); r = JsonConvert.DeserializeObject <GetLongIdResponse>(result); serviceCodeId = r.returnedId; //check for presence of plant - add if not present long containerId = 0; ContainerDTO containerDTO = GetContainerDTO(kvp); string jsonData = JsonConvert.SerializeObject(containerDTO); StringContent content = new StringContent(jsonData, Encoding.UTF8, "application/json"); result = Post("DoesContainerExist", content); r = JsonConvert.DeserializeObject <GetLongIdResponse>(result); containerId = r.returnedId; //check for presence of inventory - add if not present ImportContainerRequest request = new ImportContainerRequest(); //add image if present if (img != null) { ImageConverter imgCon = new ImageConverter(); request.imageBytes = (byte[])imgCon.ConvertTo(img.Image, typeof(byte[])); } //create DTO - send to service - backend will do the hookup request.ContainerSize = containerSize; if (containerNameId == 0) { request.ContainerName = containerName; } else { request.AddContainerRequest.Container.ContainerNameId = containerNameId; } if (containerTypeId == 0) { request.ContainerType = containerType; } else { request.AddContainerRequest.Container.ContainerTypeId = containerTypeId; } request.ServiceCode = GetServiceCodeDTO(kvp); if (serviceCodeId > 0) { ServiceCodeDTO original = GetServiceCodeById(serviceCodeId); UpdateServiceCode(original, request.ServiceCode); request.ServiceCode = original; request.ServiceCode.ServiceCodeId = serviceCodeId; request.AddContainerRequest.Inventory.ServiceCodeId = serviceCodeId; } jsonData = JsonConvert.SerializeObject(request); content = new StringContent(jsonData, Encoding.UTF8, "application/json"); Post("ImportContainer", content); }
private ContainerDTO GetContainerDTO(KeyValuePair <int, List <ExcelRowData> > kvp) { ContainerDTO dto = new ContainerDTO(); return(dto); }
public InvalidTokenRuntimeException(ActivityDTO activityDTO, ContainerDTO containerDTO, string message) : base(activityDTO, containerDTO, message) { }
public InvalidTokenRuntimeException(ContainerDTO containerDTO, string message) : base(message, null) { ContainerDTO = containerDTO; }
private void ValidateContainer(ContainerDTO container) { //Activity Responses should be resetted Assert.AreEqual(null, container.CurrentActivityResponse); Assert.AreEqual("ShowTableReport", container.CurrentClientActivityName); }
public virtual void BindTo(ContainerDTO dto) { _gridBinder.BindToSource(dto.Tags); _screenBinder.BindToSource(dto); initNameControl(dto); }
private void onNameSet(ContainerDTO container, PropertyValueSetEventArgs <string> e) { OnEvent(() => _presenter.SetInitialName(e.NewValue)); }
private void onValueUpdating <T>(ContainerDTO container, PropertyValueSetEventArgs <T> e) { OnEvent(() => _presenter.SetPropertyValueFromView(e.PropertyName, e.NewValue, e.OldValue)); }