public JsonResult AddPutback(MSI_PutBackForm _putbackform) { MSIPutBackFormRepository repository; _putbackform.IsActive = true; try { repository = new MSIPutBackFormRepository(); if (_putbackform.ID > 0) { repository.Update(_putbackform); } else { repository.Add(_putbackform); } } catch (Exception ex) { } //return _dpsform; return Json(_putbackform, JsonRequestBehavior.AllowGet); }
public bool PerformFileUploadOperationPutBack(MSI_PutBackForm _putbackForm, IEnumerable<HttpPostedFileBase> FilesCollection) { Cascade.Data.Repositories.MSIPutBackFormRepository repository = new MSIPutBackFormRepository(); string _allMediaDocuments = ""; //set document name if we already have one and already uploaded in the past _allMediaDocuments = (_putbackForm.CheckDocuments == null) ? "" : _putbackForm.CheckDocuments; //get GUID string _additionalIdentifier = Guid.NewGuid().ToString(); //Get all fileNames together so store in the Database foreach (var file in FilesCollection) { if (file != null) { if (_allMediaDocuments.Length > 0) { _allMediaDocuments = _allMediaDocuments + "|" + _additionalIdentifier + "_" + file.FileName; } else { _allMediaDocuments = _additionalIdentifier + "_" + file.FileName; } } } //Now Upload and set the properties foreach (var file in FilesCollection) { if (file != null) { if (file.ContentLength > 0) { //Upload the file fileProcessor.SaveUploadedFileWithIdentifier(file, _additionalIdentifier); } } } if (_allMediaDocuments != "") { //Perform Save Operation _putbackForm.CheckDocuments = _allMediaDocuments; repository.Update(_putbackForm); } //response return true; }
public ActionResult UploadAllDocumentsPutBack(IEnumerable<HttpPostedFileBase> checkDocuments) { //Let us get Id of newly created reocrd string _addedPutBackRecordID = Request.Form["hdnPutbackRecordID"]; //If ID is not null then go ahaead if (_addedPutBackRecordID != null) { int _recordID = 0; //Gather the Info _recordID = Convert.ToInt32(_addedPutBackRecordID); //Get the Info from the Repository Cascade.Data.Repositories.MSIPutBackFormRepository repository = new MSIPutBackFormRepository(); Cascade.Data.Models.MSI_PutBackForm _putbackForm = (from existingForm in repository.GetAll().Where(record => record.ID == _recordID) select existingForm).First(); _putbackForm.UploadedOn = DateTime.Now; _putbackForm.IsActive = true; _putbackForm.UploadedBy = UserId.ToString(); #region [[ Check Images ]] if (checkDocuments != null) { if (checkDocuments.Count() >= 1) { PerformFileUploadOperationPutBack(_putbackForm, checkDocuments); } } #endregion //Redirect to View Edit Form return RedirectToAction("DetailsPutback", "Recall", new { id = _putbackForm.ID }); } else { //Something is wrong so go to main page return RedirectToAction("PutBackIndex", "Recall"); } }
public JsonResult GetPutbackData(int id) { MSIPutBackFormRepository portRecallRepo = new MSIPutBackFormRepository(); var _portRecallData = from _portRecall in portRecallRepo.GetAll().Distinct() where _portRecall.ID == id select _portRecall; return Json(_portRecallData.SingleOrDefault(), JsonRequestBehavior.AllowGet); }