public static bool Update(UserExternalListing externalListing) { externalListing.AutoRegisterUserJobTitles(); var sqlUpdate = @" UPDATE UserExternalListing SET title = @2, jobTitles = @3, notes = @4, UpdatedDate = getdate() WHERE UserID = @0 AND UserExternalListingID = @1 AND Active = 1 "; using (var db = new LcDatabase()) { var affected = db.Execute(sqlUpdate, externalListing.userID, externalListing.userExternalListingID, externalListing.title, Newtonsoft.Json.JsonConvert.SerializeObject(externalListing.jobTitles), externalListing.notes ); // Task done? Almost a record must be affected to be a success return(affected > 0); } }
/// <summary> /// /// </summary> /// <param name="externalListing"></param> /// <returns>Generated ID</returns> public static int Insert(UserExternalListing externalListing) { externalListing.AutoRegisterUserJobTitles(); var sqlInsert = @" INSERT INTO UserExternalListing ( UserID, PlatformID, Title, JobTitles, Notes, CreatedDate, UpdatedDate, ModifiedBy, Active ) VALUES ( @0, @1, @2, @3, @4, getdate(), getdate(), 'sys', 1 ) SELECT @@Identity "; using (var db = new LcDatabase()) { return((int)db.QueryValue(sqlInsert, externalListing.userID, externalListing.platformID, externalListing.title, Newtonsoft.Json.JsonConvert.SerializeObject(externalListing.jobTitles), externalListing.notes )); } }