public bool EditOne(GradeAndSection p, ref string msg) { MySqlCommand command = new MySqlCommand(); command.CommandText = "EditGradeAndSection"; command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("intId", p.Id).Direction = ParameterDirection.Input; command.Parameters.AddWithValue("strTitle", p.Title).Direction = ParameterDirection.Input; command.Parameters.AddWithValue("intGradeId", p.GradeId).Direction = ParameterDirection.Input; command.Parameters.AddWithValue("intSectionId", p.SectionId).Direction = ParameterDirection.Input; command.Parameters.AddWithValue("intModifiedById", p.ModifiedById).Direction = ParameterDirection.Input; command.Parameters.AddWithValue("itExists", MySqlDbType.Bit).Direction = ParameterDirection.Output; try { MyHelper.ExecuteNonQuery(command, ref msg); if ((int)command.Parameters["itExists"].Value == 0) { return(true); } msg = msg + "\nThis item is already in the database"; return(false); } catch (Exception ex) { msg = ef.GetExceptionMessage(ex, msg); return(false); } }
private GradeAndSection MapProperties(GradeAndSectionVm p) { GradeAndSection baseObj = new GradeAndSection(); baseObj.Id = p.Id.GetInt(); baseObj.Title = p.Title.GetString(); baseObj.GradeId = p.GradeId.GetInt(); baseObj.SectionId = p.SectionId.GetInt(); baseObj.CreatedById = p.CreatedById.GetInt(); baseObj.CreatedOn = p.CreatedOn.GetDateTime(); baseObj.ModifiedById = p.ModifiedById.GetInt(); baseObj.ModifiedOn = p.ModifiedOn.GetNullableDateTime(); return(baseObj); }
public bool DeleteOne(GradeAndSection p, ref string msg) { MySqlCommand command = new MySqlCommand(); command.CommandText = "DeleteGradeAndSection"; command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("intId", p.Id).Direction = ParameterDirection.Input; try { return(MyHelper.ExecuteNonQuery(command, ref msg)); } catch (Exception ex) { msg = ef.GetExceptionMessage(ex, msg); return(false); } }