Example #1
0
File: Area.cs Project: v1ku/HA4IoT
        public void AddComponent(IComponent component)
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            _components.AddUnique(component.Id, component);
            _componentService.AddComponent(component);
        }
Example #2
0
        public async Task <JsonResult> CreateCmp(IFormFile PictureUrl, int ProductId)
        {
            if (PictureUrl != null && PictureUrl.Length > 0 && ProductId > 0)
            {
                var ComponentFileName = Guid.NewGuid() + Path.GetExtension(PictureUrl.FileName);
                var ProductFilePath   = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\images\Pictures", ComponentFileName);
                using (var fileStream = new FileStream(ProductFilePath, FileMode.Create))
                {
                    await PictureUrl.CopyToAsync(fileStream);
                }

                var rez = await _IComponentService.AddComponent(ComponentFileName, ProductId);

                if (rez)
                {
                    return(Json(true));
                }
                return(Json(false));
            }
            return(Json(false));
        }