public async Task <int> AddComponent(/*BuyerComponentBodyModel buyerComponentBodyModel*/) { try { BuyerComponentBodyModel buyerComponentBodyModel = new BuyerComponentBodyModel(); var httpRequest = HttpContext.Current.Request; //int buyerId = Convert.ToInt32(httpRequest.Form["BuyerId"]); //int buyerCategoryId = Convert.ToInt32(httpRequest.Form["BuyerCategoryId"]); string component = httpRequest.Form["Component"]; int isActive = Convert.ToInt32(httpRequest.Form["IsActive"]); //buyerComponentBodyModel.BuyerId = buyerId; //buyerComponentBodyModel.BuyerCategoryId = buyerCategoryId; buyerComponentBodyModel.Component = component; buyerComponentBodyModel.IsActive = isActive; var result = await _buyerRepository.AddComponent(buyerComponentBodyModel); if (result > 0) { if (httpRequest.Files.Count > 0) { foreach (string file in httpRequest.Files) { var postedFile = httpRequest.Files[file]; if (postedFile != null && postedFile.ContentLength > 0) { IList <string> AllowedFileExtensions = new List <string> { ".png" }; var ext = postedFile.FileName.Substring(postedFile.FileName.LastIndexOf('.')); var extension = ext.ToLower(); if (AllowedFileExtensions.Contains(extension)) { var filePath = HttpContext.Current.Server.MapPath("~/Images/Components/" + component.ToLower() + extension); postedFile.SaveAs(filePath); } } } } } return(result); } catch (Exception exception) { throw exception; } }