public int Add(FileHeader fileHeaderObj, bool doSubmit) { //Set lastmodified fields fileHeaderObj.LastModifiedBy = _SessionUsr.ID; fileHeaderObj.LastModifiedDate = DateTime.Now; dbc.FileHeaders.InsertOnSubmit(fileHeaderObj); if (doSubmit) dbc.SubmitChanges(); return fileHeaderObj.ID; // Return the 'newly inserted id' }
public int AddEdit(FileHeader fileHeaderObj, bool doSubmit) { fileHeaderObj.UploadedOn = Defaults.getValidDate(fileHeaderObj.UploadedOn); // special case to ensure valid SQLDate if (fileHeaderObj.ID <= Defaults.Integer) // Insert return Add(fileHeaderObj, doSubmit); else { #region Update //Set lastmodified fields fileHeaderObj.LastModifiedBy = _SessionUsr.ID; fileHeaderObj.LastModifiedDate = DateTime.Now; dbc.FileHeaders.Attach(fileHeaderObj);//attach the object as modified dbc.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, fileHeaderObj);//Optimistic-concurrency (simplest solution) #endregion if (doSubmit) //Make a FINAL submit instead of periodic updates dbc.SubmitChanges(); } return fileHeaderObj.ID; }
FileHeader Transform(FileHeader f, string fileHeaderBy, string fileTypeTitle, int claimID) { /*also set .Claim = null to avoid issues during serialization but persist ClaimID as ClaimID1 */ return f.Set(f1 => { f1.UploadedBy = fileHeaderBy; f1.FileTypeTitle = fileTypeTitle; f1.ClaimGUID = f1.ClaimID.ToString(); /*f1.Claim = null; f1.ClaimID1 = claimID; NOT needed because we've set the Association Access to Internal in the dbml*/}); }
private void detach_FileHeaders(FileHeader entity) { this.SendPropertyChanging(); entity.Claim = null; }
public void Delete(FileHeader fileHeaderObj, bool doSubmit) { dbc.FileHeaders.DeleteOnSubmit(dbc.FileHeaders.Single(f => f.ID == fileHeaderObj.ID)); if (doSubmit) dbc.SubmitChanges(); }
partial void DeleteFileHeader(FileHeader instance);
private void attach_FileHeaders(FileHeader entity) { this.SendPropertyChanging(); entity.Claim = this; }
partial void UpdateFileHeader(FileHeader instance);
partial void InsertFileHeader(FileHeader instance);
private void detach_FileHeaders(FileHeader entity) { this.SendPropertyChanging(); entity.MasterFileTypeHeader = null; }
public JsonResult FilesKOVM(int ClaimID, string ClaimGUID, int? FileID) { //Set File object FileHeader newObj = new FileHeader() { ID = -1, _Added = true, ClaimID = ClaimID, ClaimGUID = ClaimGUID, UploadedBy = _SessionUsr.Email, LastModifiedBy = _SessionUsr.ID, LastModifiedDate = DateTime.Now, UploadedOn = DateTime.Now, UserID = _SessionUsr.ID, Archived = false, FileName="", FileNameNEW="" }; List<FileHeader> files = new List<FileHeader>(); DAL.FileKOModel vm = new FileKOModel() { FileToAdd = newObj, EmptyFileHeader = newObj, AllFiles = (new FileHeaderService().Search(ClaimID, null)) }; // Lookup data vm.FileTypes = new LookupService().GetLookup(LookupService.Source.FileHeader); return Json(vm, JsonRequestBehavior.AllowGet); }
public ActionResult FilePostKO(int ClaimID, string ClaimGUID, FileHeader FileHdrObj) { HttpPostedFileBase hpFile = Request.Files["FileNameNEW"]; bool success = true; string result = "";// "Uploaded " + hpFile.FileName + "(" + hpFile.ContentLength + ")"; #region New file upload if ((FileHdrObj.FileNameNEW ?? FileHdrObj.FileName) != null) {//HT Delete old\existing file? For Async need to wait until final commit //HT:IMP: Set Async so that now the file maps to Async file-path FileHdrObj.IsAsync = true; //FileHdrObj.ClaimGUID = _Session.Claim.ClaimGUID; // to be used further #region Old code (make sure the function 'ChkAndSaveClaimFile' does all of it) //string docName = string.Empty; //FileIO.result uploadResult = SaveClaimFile(Request.Files["FileNameNEW"], ref docName, ClaimID, true); //if (uploadResult != FileIO.result.successful) // if (uploadResult == FileIO.result.duplicate) // ModelState.AddModelError("FileName", "Duplicate file found"); // else // ModelState.AddModelError("FileName", "Unable to upload file"); #endregion FileHdrObj.FileName = ChkAndSaveClaimFile("FileNameNEW", ClaimID, HeaderFM, FileHdrObj.ClaimGUID); success = (ModelState["FileName"].Errors.Count() < 1); } #endregion result = !success ? ("Unable to upload file - " + ModelState["FileName"].Errors[0].ErrorMessage) : ""; //Taconite XML return this.Content(Defaults.getTaconiteResult(success, Defaults.getOprResult(success, result), "fileOprMsg", "fileUploadResponse('" + FileHdrObj.CodeStr + "'," + success.ToString().ToLower() + "," + FileHdrObj.ID + ")"), "text/xml"); }