Exemple #1
0
        public async Task <ActionResult> SaveCompanyFiles(IEnumerable <HttpPostedFileBase> files, int companyId)
        {
            if (files != null)
            {
                CompanyDocumentViewModel obj = new CompanyDocumentViewModel();
                foreach (var file in files)
                {
                    var DocumentId   = Guid.NewGuid().ToString();
                    var fileName     = Path.GetFileName(file.FileName);
                    var physicalPath = Path.Combine(Server.MapPath("~/Uploads/Companies"), DocumentId);
                    //file.SaveAs(physicalPath + "_" + companyId);
                    file.SaveAs(physicalPath);
                    obj.AccountId  = companyId;
                    obj.DocumentId = DocumentId;
                    obj.FileName   = fileName;
                }
                //string url = "http://localhost:23438/Api/AccountDocumentMapping/Create";
                //HttpClient client = new HttpClient();
                //client.BaseAddress = new Uri(url);
                //client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                //HttpResponseMessage responseMessage = await client.PostAsJsonAsync<CompanyDocumentViewModel>(url, obj);
                var webApi = new AccountDocumentMappingController();
                webApi.Create(obj);
            }

            return(Content(""));
        }
 public async Task <IHttpActionResult> Create(CompanyDocumentViewModel obj)
 {
     try
     {
         this._businessLayer.CompanyUpload(obj);
         return(StatusCode(HttpStatusCode.Created));
     }
     catch (Exception ex)
     {
         this.ExceptionLogger.Log(LogLevel.Error, ex);
         throw ex;
     }
 }
Exemple #3
0
        public async Task <CompanyDocumentViewModel> CompanyUpload(CompanyDocumentViewModel accountDocumentMapping)
        {
            AccountDocumentMapping obj = new AccountDocumentMapping
            {
                DocumentId = accountDocumentMapping.DocumentId,
                AccountId  = accountDocumentMapping.AccountId,
                FileName   = accountDocumentMapping.FileName
            };

            var companyInfo = this.AccountDocumentMappingRepository.Add(obj);

            return(new CompanyDocumentViewModel
            {
                DocumentId = companyInfo.DocumentId,
                AccountId = companyInfo.AccountId,
                FileName = companyInfo.FileName
            });
        }
Exemple #4
0
        public async Task <IActionResult> Create(CompanyDocumentViewModel model)
        {
            model.SystemUserId = UserId;

            if (ModelState.IsValid)
            {
                ViewBag.Active = "Create";
                var item = _mapper.Map <CompanyDocumentViewModel, CompanyDocument>(model);
                await _companyDocumentRepository.InsertAsync(item);

                ErrorMessage = Resources.Messages.ChangesSavedSuccessfully;
                if (Request.Form.Keys.Contains("SaveAndReturn"))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("Edit", new { id = item.Id }));
                }
            }
            return(View(model));
        }