public async Task AddProductAsync(AddProductViewModel model, HttpPostedFileBase file) { await ChangeViewModel(model); try { if (file.ContentLength > 0) { model.FileName = Path.GetFileName(file.FileName); string _path = Path.Combine(HostingEnvironment.MapPath("~/Content/Products"), model.FileName); file.SaveAs(_path); } } catch { throw new Exception("Nie udało się dodać pliku"); } model.ProductId = Guid.NewGuid(); var product = _mapper.Map <AddProductViewModel, Product>(model); await _productRepo.AddProductAsync(product); }