public void SaveMaterialAttachment(EductionMaterial objEdu, Int64 MaterialId) { try { if (Connection.State == ConnectionState.Open) { Connection.Close(); } Connection.Open(); foreach (var path in objEdu.AttachmentPath) { command.Parameters.Clear(); command.Connection = Connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "USP_InsertEducationMaterialAttachment"; command.Parameters.AddWithValue("@MaterialId", MaterialId); command.Parameters.AddWithValue("@UserId", objEdu.UserId); command.Parameters.AddWithValue("@Path", path.ToString()); int RowsAffected = command.ExecuteNonQuery(); } } catch (Exception ex) { clsError.WriteException(ex); } finally { if (Connection != null) { Connection.Close(); } } }
// DataSet _dataset = null; public bool SaveEducationMaterial(EductionMaterial objEdu) { bool isInserted = false; try { command.Parameters.Clear(); if (Connection.State == ConnectionState.Open) { Connection.Close(); } Connection.Open(); command.Connection = Connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "USP_InsertEducationMaterial"; if (!string.IsNullOrEmpty(objEdu.Id)) { command.Parameters.AddWithValue("@Id", objEdu.Id); } command.Parameters.AddWithValue("@Group", objEdu.Group); command.Parameters.AddWithValue("@Title", objEdu.Title); command.Parameters.AddWithValue("@Description", objEdu.Description); command.Parameters.AddWithValue("@URL", objEdu.URL); command.Parameters.AddWithValue("@URLNote", objEdu.URLNote); command.Parameters.AddWithValue("@UserId", objEdu.UserId); command.Parameters.AddWithValue("@AgencyId", objEdu.AgencyId); Object Note = command.ExecuteScalar(); if (Note != null && objEdu.AttachmentPath != null && objEdu.AttachmentPath.Length > 0) { Int64 NoteID = Convert.ToInt64(Note); SaveMaterialAttachment(objEdu, NoteID); isInserted = true; } } catch (Exception ex) { clsError.WriteException(ex); } finally { if (Connection != null) { Connection.Close(); } } return(isInserted); }
public ActionResult SaveEducationMaterial(EductionMaterial objEductaion) { bool Result = false; try { if (objEductaion != null) { objEductaion.UserId = Session["UserID"].ToString(); objEductaion.AgencyId = Session["AgencyID"].ToString(); Result = new EducationMaterialData().SaveEducationMaterial(objEductaion); } } catch (Exception Ex) { clsError.WriteException(Ex); } return(Json(Result)); }