public async Task <dynamic> DeleteDocType(DSM_DocType objDocType) { _action = "delete"; _respStatus = await Task.Run(() => _docTypeService.ManipulateDocType(objDocType, _action, out _outStatus)); return(Json(new { Message = _respStatus.Message, _respStatus }, JsonRequestBehavior.AllowGet)); }
public ValidationResult ManipulateDocType(DSM_DocType docType, string action, out string status) { _docTypeDataService.ManipulateDocType(docType, action, out status); if (status.Length > 0) { return(new ValidationResult(status, _localizationService.GetResource(status))); } return(ValidationResult.Success); }
public async Task <dynamic> EditDocType(DSM_DocType objDocType) { if (ModelState.IsValid) { _action = "edit"; objDocType.SetBy = UserID; objDocType.ModifiedBy = objDocType.SetBy; _respStatus = await Task.Run(() => _docTypeService.ManipulateDocType(objDocType, _action, out _outStatus)); return(Json(new { Message = _respStatus.Message, _respStatus }, JsonRequestBehavior.AllowGet)); } else { _respStatus = new ValidationResult("E404", _localizationService.GetResource("E404")); } return(Json(new { Message = _respStatus.Message, _respStatus }, JsonRequestBehavior.AllowGet)); }
public string ManipulateDocType(DSM_DocType docType, string action, out string errorNumber) { errorNumber = string.Empty; try { var factory = new DatabaseProviderFactory(); var db = factory.CreateDefault() as SqlDatabase; using (var dbCommandWrapper = db.GetStoredProcCommand("SetDocType")) { // Set parameters db.AddInParameter(dbCommandWrapper, "@DocTypeID", SqlDbType.NVarChar, docType.DocTypeID); db.AddInParameter(dbCommandWrapper, "@OwnerID", SqlDbType.NVarChar, docType.OwnerID); db.AddInParameter(dbCommandWrapper, "@DocCategoryID", SqlDbType.NVarChar, docType.DocCategoryID); db.AddInParameter(dbCommandWrapper, "@DocTypeSL", SqlDbType.NVarChar, docType.DocTypeSL); db.AddInParameter(dbCommandWrapper, "@UDDocTypeCode", SqlDbType.NVarChar, docType.UDDocTypeCode); db.AddInParameter(dbCommandWrapper, "@DocTypeName", SqlDbType.NVarChar, docType.DocTypeName); db.AddInParameter(dbCommandWrapper, "@DocPreservationPolicy", SqlDbType.NVarChar, docType.DocPreservationPolicy); db.AddInParameter(dbCommandWrapper, "@DocPhysicalLocation", SqlDbType.NVarChar, docType.DocPhysicalLocation); db.AddInParameter(dbCommandWrapper, "@SetBy ", SqlDbType.NVarChar, docType.SetBy); db.AddInParameter(dbCommandWrapper, "@ModifiedBy", SqlDbType.NVarChar, docType.ModifiedBy); db.AddInParameter(dbCommandWrapper, "@Status", SqlDbType.Int, docType.Status); db.AddInParameter(dbCommandWrapper, "@ClassificationLevel", SqlDbType.Int, docType.ClassificationLevel); db.AddInParameter(dbCommandWrapper, "@DocClassification", SqlDbType.Int, docType.DocClassification); db.AddInParameter(dbCommandWrapper, "@Action", SqlDbType.VarChar, action); db.AddOutParameter(dbCommandWrapper, spStatusParam, SqlDbType.VarChar, 10); // Execute SP. db.ExecuteNonQuery(dbCommandWrapper); // Getting output parameters and setting response details. if (!db.GetParameterValue(dbCommandWrapper, spStatusParam).IsNullOrZero()) { // Get the error number, if error occurred. errorNumber = db.GetParameterValue(dbCommandWrapper, spStatusParam).PrefixErrorCode(); } } } catch (Exception ex) { errorNumber = "E404"; // Log ex.Message Insert Log Table } return errorNumber; }