public void AddComponent(IComponent component) { if (component == null) { throw new ArgumentNullException(nameof(component)); } _components.AddUnique(component.Id, component); _componentService.AddComponent(component); }
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)); }