public JsonResult Add(MSI_RecallForm _recallform)
        {
            MSIRecallFormRepository repository;
            _recallform.IsActive = true;
            try
            {
                repository = new MSIRecallFormRepository();
                if (_recallform.ID > 0)
                {
                    repository.Update(_recallform);
                }
                else
                {
                    repository.Add(_recallform);
                }
            }
            catch (Exception ex)
            {

            }
            //return _dpsform;
            return Json(_recallform, JsonRequestBehavior.AllowGet);
        }
 public ActionResult UploadAllDocuments(IEnumerable<HttpPostedFileBase> checkDocuments)
 {
     //Let us get Id of newly created reocrd
     string _addedRecallRecordID = Request.Form["hdnRecallRecordID"];
     //If ID is not null then go ahaead
     if (_addedRecallRecordID != null)
     {
         int _recordID = 0;
         //Gather the Info
         _recordID = Convert.ToInt32(_addedRecallRecordID);
         //Get the Info from the Repository
         Cascade.Data.Repositories.MSIRecallFormRepository repository = new MSIRecallFormRepository();
         Cascade.Data.Models.MSI_RecallForm _recallForm = (from existingForm in repository.GetAll().Where(record => record.ID == _recordID)
                                                           select existingForm).First();
         _recallForm.UploadedOn = DateTime.Now;
         _recallForm.IsActive = true;
         _recallForm.UploadedBy = UserId.ToString();
         #region [[ Check Images ]]
         if (checkDocuments != null)
         {
             if (checkDocuments.Count() >= 1)
             {
                 PerformFileUploadOperation(_recallForm, checkDocuments);
             }
         }
         #endregion
         //Redirect to View Edit Form
         return RedirectToAction("Details", "Recall", new { id = _recallForm.ID });
     }
     else
     {
         //Something is wrong so go to main page
         return RedirectToAction("Index", "Recall");
     }
 }
        public bool PerformFileUploadOperation(MSI_RecallForm _recallForm, IEnumerable<HttpPostedFileBase> FilesCollection)
        {
            Cascade.Data.Repositories.MSIRecallFormRepository repository = new MSIRecallFormRepository();
            string _allMediaDocuments = "";
            //set document name if we already have one and already uploaded in the past
            _allMediaDocuments = (_recallForm.CheckDocuments == null) ? "" : _recallForm.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
                _recallForm.CheckDocuments = _allMediaDocuments;
                repository.Update(_recallForm);
            }
            //response
            return true;
        }
 public JsonResult GetRecallData(int id)
 {
     MSIRecallFormRepository portRecallRepo = new MSIRecallFormRepository();
     var _portRecallData = from _portRecall in portRecallRepo.GetAll().Distinct()
                           where _portRecall.ID == id
                           select _portRecall;
     return Json(_portRecallData.SingleOrDefault(), JsonRequestBehavior.AllowGet);
 }